L
Learning SQL Server
My row insertion keeps failing while using the CommandBuilder. I believe I
know why, but I am not sure how to resolve it.
I have a datagrid that will update rows in a database, as well as add a few
more. I am adding the new row to the dataset before sending my changes back
to the database. The updates of existing rows works fine. When I insert
rows, however, I get an error stating that my column is declared as unique
and that inserting the row will violate the primary key constraint. It also
shows the numeric key value in the error, which I see is the already
assigned primary key of the row I am trying to UPDATE.
So I think I need to get the next value of the primary key of the table and
assign this to the row I am creating and adding to my dataset. But how do I
do this?
Again, my updates are working fine, but Insertions fail. Basically I thought
you could do both insertions and updates with a single CommandBuilder object
but it doesnt appear to be the case...
know why, but I am not sure how to resolve it.
I have a datagrid that will update rows in a database, as well as add a few
more. I am adding the new row to the dataset before sending my changes back
to the database. The updates of existing rows works fine. When I insert
rows, however, I get an error stating that my column is declared as unique
and that inserting the row will violate the primary key constraint. It also
shows the numeric key value in the error, which I see is the already
assigned primary key of the row I am trying to UPDATE.
So I think I need to get the next value of the primary key of the table and
assign this to the row I am creating and adding to my dataset. But how do I
do this?
Again, my updates are working fine, but Insertions fail. Basically I thought
you could do both insertions and updates with a single CommandBuilder object
but it doesnt appear to be the case...