Showing posts with label assume. Show all posts
Showing posts with label assume. Show all posts

Monday, March 12, 2012

Run multiple query on VB 2005

Assume that I got 10 line of insert query to be carry out, how can I run all these 10 insert query at on time instead of using sqlcommand.executenonquery for 10 time. Thanks.

You can create a Stored Procedure that contains all 10 queries, pass all of the necessary parameters to the Stored Procedure, and the execute the Stored Procedure.

Perhaps if you posted your queries, we could better help you.

|||Well, if I got one or two insert query, one or two delete query and some update query, assume that the data validation is valid, could these be carry out together?|||

Yes.

In the Stored Procedure, if they are 'all or none' actions, you may wish to put all of the queries/actions in a SQL TRANSACTION to make sure that there are no errors.

|||Can I have a sample code on how to execute multiple queries at one time?|||Look in Books Online for the topic 'TRANSACTION'. There are several good examples.