Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
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 21-Sep-12 19:48pm
v2
Comments
DaveAuld at 22-Sep-12 1:58am
   
Terminate each half of the statement using a semi-colon. 'update fist table; update second table'
DaveAuld at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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)
  Permalink  

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

  Print Answers RSS
0 CHill60 320
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 173
3 OriginalGriff 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid