The documentation says that LoadDataRow updates or inserts based upon whether the row exists or not. It does not say so in the documentation, but I figured the only way for it to know that is for it to check the Primary key. So, in my dataset, I defined a Primary key for the table, like this:
Dim keyColumn(1) As DataColumn
keyColumn(0) = ds.Tables(TableName).Columns(i)
ds.Tables(TableName).PrimaryKey = keyColumn
Now when I use the following:
Dim NewRow(4) As Object
NewRow(0) = intProfileID
NewRow(1) = DropDownProfiles.Text.Trim
NewRow(2) = 1
NewRow(3) = txtBoxProfileDescription.Text.Trim
NewRow(4) = txtBoxPassword.Text
drins = ds.Tables("Profiles").LoadDataRow(NewRow, True)
I get an error message saying "Column 'ProfileID' is constrained to be unique. Value '2' is already present." In other words, it will not update, only insert. I have been forced to delete each row I want to update and then reinsert.
What gives?
TIA,
AG
Dim keyColumn(1) As DataColumn
keyColumn(0) = ds.Tables(TableName).Columns(i)
ds.Tables(TableName).PrimaryKey = keyColumn
Now when I use the following:
Dim NewRow(4) As Object
NewRow(0) = intProfileID
NewRow(1) = DropDownProfiles.Text.Trim
NewRow(2) = 1
NewRow(3) = txtBoxProfileDescription.Text.Trim
NewRow(4) = txtBoxPassword.Text
drins = ds.Tables("Profiles").LoadDataRow(NewRow, True)
I get an error message saying "Column 'ProfileID' is constrained to be unique. Value '2' is already present." In other words, it will not update, only insert. I have been forced to delete each row I want to update and then reinsert.
What gives?
TIA,
AG