Hi,
How to execute multiple queries with one connection in vb.net.
I am using windows vb.net with Access DB.
In my project i need to delete the records of 15 tables.
Every time i need to open the connection and close the connection for every delete statement.
Same way i need to insert the records for 15 to 20 tables.
It took lot of time to execute.
is it possible to delete the records from multiple tables with one connections?
Need code for this
Sucharitha
Loading
Hemant SrivastavaPosted Jul 17, 2013, 4:42 PM
Vikash MahataPosted Jul 17, 2013, 3:17 PM
Try like this:
Try
conn.Open()
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
cmd3.ExecuteNonQuery()
cmd4.ExecuteNonQuery()
...............................
................................
cmd15.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
End Try
suchi ranaPosted Jul 17, 2013, 8:07 AM
Kunal VaishyaPosted Jul 17, 2013, 8:01 AM
you can set multiple Query for delete in one command in Command Text
Refer this link for More
http://www.codeproject.com/Articles/306722/Executing-multiple-SQL-statements-as-one-against-S