Setting the Primary key of a DataTable

K

KJ

I have a Datatable with 1 datarow in it. When I try to set the primary
key I get an error back saying that the columns in the datatable are
not unique.


How do I fix it?
 
C

Cowboy \(Gregory A. Beamer\)

You need a unique value to set a primary key. As I am not sure how you are
getting dupes, I am not sure how to progress. Here is a guess.

You are probably using a query that pulls from multiple tables. This is
creating dupes due to the joins. You can do one of the following things, if
this is true.

1. Add further conditions on the SQL join statement or use DISTINCT when you
pull the values (not sure the syntax if this is not SQL Server).
2. Pull each table as a separate DataTable and add relationships to your
DataSet.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top