Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my datagrid view adapter select the data based on the where condition. And at the same time I need to add one or two new row values and update in same where condition. How can I do this. Anyone guide me
Posted

ok, First let me know how could you insert a new record in SQL with Where criteria with variables ?

you don't have to worry about where criteria, when you are passing values from UI, just insert record in database :) Isn't that simple?
 
Share this answer
 
Hello ,
If I am not wrong you want to update the previous record as well as insert the new record in database . I think you can use one extra column in the datagridview along with the other columns , which will store the status of the record , whether it was updated or inserted(for first time). Say 0 for Insert and 1 for Update. Now , pass the column value in Store procedure or sql . and check if the value is 0 then run the insert query or else run update query .
 
Share this answer
 

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