Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have multiple update queries which update a row in table ,so it is like lock a row update the changes and unlock the row.

Now instead of executing executenonquery 3 times i want to execute it only once .

Can it be done ...


Thanks You..
Posted

Yes, the queries need to seperated by semi-colon ";"

eg:
C#
string query = "insert into table1(x,y,z); update table2 set a = 23;"
OledbCommand cmd = new OledbCommand(query, connection);
.
.
.
cmd.ExecuteNonQuery();
 
Share this answer
 
v2
Comments
P.Salini 29-May-12 7:55am    
my 5
Yes, it can be; Microsoft Access supports Transactions [^]and they work quite well.

Even so, if possible, use SQL Server Express. It's much more powerful than Access.
 
Share this answer
 
Comments
Maciej Los 29-May-12 7:50am    
Good answer, my 5!
Prasad_Kulkarni 29-May-12 7:58am    
Thank you Isomac!
P.Salini 29-May-12 7:55am    
my 5
Prasad_Kulkarni 29-May-12 7:58am    
Thank you Salini!
If You want to execute multiple query same time then create sring with all statement and execute it.
Like:
string strQuery = " Insert into tbl values(1,1);Update tbl set fld=value where id=id;update tbl2 set fld=value where id=id;";
 
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