Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all visitors
i created one table in sql server 2005. In my table has 3 fields( code,name,location)
the field code is the primary key and in column property in sql, i use (is Identity)=yes, identity increment=1 and identity seed=1.
In, i created one dataset and link to my table.on form, i created one DataGridView and the datasource of that dataGridView is the datasource above.
but in the datagridview, i removed column "Code" in in my datagridview shows only 2 columns(name,location).in my button Save Source code, i write like this:

i input 3 rows in datagridview, but i can save only 1 row to my table and it also alert error message that "Column 'Code' is constrained to be unique. Value '1' is already present".

How can i save all rows in datagridview to my table at the first time?
Best Regards,

1 solution

Try to add a string equals "" then put it in your Save source code
Share this answer
soeun tony 23-May-11 22:53pm    
Thanks for your reply
but field code in that table can't be null or ""
coz it will be used to other table.
Best Regards,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900