Click here to Skip to main content
15,885,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I want to update my values in Datagridview which are coming from 2 tables...how can i update the values in a single sql statement....can anyone help me????please....
Posted
v2
Comments
DaveAuld 22-Sep-12 1:58am    
Terminate each half of the statement using a semi-colon. 'update fist table; update second table'
DaveAuld 22-Sep-12 1:59am    
You haven't said if the table data is related, how did you pull the data through to the datagridview?

1 solution

You can use Transactions - either at code level or DB level based on your workflow and need.

Here:
MSDN: BEGIN TRANSACTION (Transact-SQL)[^]
SQL Server Transactions and Error Handling[^]

MSDN: Local Transactions[^]
Using Transactions in ADO.NET[^]
Bulk Insert into SQL from C# App[^]


Further, if it's independent and not related data's of two table, then it can be sent to DB in one shot where you can execute two updates sequentially (UPDATE table1; UPDATE table2)
 
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