LoadDataRow - Inserts or Updates?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte

    LoadDataRow - Inserts or Updates?

    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(Table Name).Columns(i )

    ds.Tables(Table Name).PrimaryKe y = keyColumn

    Now when I use the following:

    drins = MyDataSet.Table s("Profiles").L oadDataRow(NewR ow, 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.

    What gives?

    TIA,

    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving





Working...