Click here to Skip to main content
12,295,791 members (46,409 online)
Rate this:
 
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 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

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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100