Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding primary key to existing dataSet

Status
Not open for further replies.

gharabed

Programmer
Sep 7, 2001
251
US
How would I add a "primary key" to an existing variable of the type dataSet? I tried something like:

resultDataSet.Tables(0).PrimaryKey(0) = resultDataSet.Tables(0).Columns("ParticipantID")

where I only have one table in my dataset and the pk would be the "ParticipantID" column. However, I get an index out of range error. Any ideas?
 
You have to set it to an array. Something like:
Code:
        Dim dc As DataColumn() = {resultDataSet.Tables(0).Columns("ParticipantID")}
        resultDataSet.Tables(0).PrimaryKey = dc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top