G
Guest
Ok. I have a table with a primary key being an integer. When using VS.NET 2002, it could not create an update command for my table. Being SQL savvy, I created my own update statement below
Me.SqlCommand4.CommandText = "UPDATE dbo.links_page SET (title=@title, imageurl=@imageurl) WHERE (link_page_id = @link_page_id); SELECT title, link_page_id, imageurl FROM dbo.links_page
It is bound to the SqlDataAdapter I created. When I add a new record, it is getting the proper auto-increment values, and when I execute .Update(myDataSet), the record is added to the database table
But after that record is added, it gives me a constraint error. Apparently, it is having a problem with records that are already in the table. It looks like it is attempting to insert copies of them into the table (which violates my primary key.
The exact error is
Column 'link_page_id' is constrained to be unique. Value '2' is already present
How do I fix this problem
Me.SqlCommand4.CommandText = "UPDATE dbo.links_page SET (title=@title, imageurl=@imageurl) WHERE (link_page_id = @link_page_id); SELECT title, link_page_id, imageurl FROM dbo.links_page
It is bound to the SqlDataAdapter I created. When I add a new record, it is getting the proper auto-increment values, and when I execute .Update(myDataSet), the record is added to the database table
But after that record is added, it gives me a constraint error. Apparently, it is having a problem with records that are already in the table. It looks like it is attempting to insert copies of them into the table (which violates my primary key.
The exact error is
Column 'link_page_id' is constrained to be unique. Value '2' is already present
How do I fix this problem