Creating a collection of command Type objects

  • Thread starter Thread starter Venkatesh
  • Start date Start date
V

Venkatesh

Hi

I will need to execute several parametrized stored
procedures individually. What I am looking for is a method
by which I can fill a collection of commandtext,command
type and parameter objects , construct a string and call
all the stored procedures at once without having to make
multiple round trips to the server.

Venkatesh
 
<<exec SP2 p1,p2, Exec SP3 p1,p2,p3>> Won't run in SQL
Server, it's going to think ,Exec SP3... are all params
for the first. You'd need a Go in between them, assuming
you told the command that these weren't stored procs.

But I tried it using Carriage Returns in between and Go
Statements without specifying the stored procedure comment
and it wasn't happening.

If you are going to use named Parameters instead of
literals then it definitely won't work

If you are planning on using the StoredProcedure
constanat, won't work either. The commandtext property
needs to equal the name of the proc if you set it's type
to StoredProcedure....and your name will be taken as a
literal. You can run multiple SQL queries but that query
is still being executed against the DB and the query data
still has to go from commandtext to the db and the result
data needs to come back to the client. This is
effectively the same as leaving a connection open and
firing three commands against it without having them in a
batch.

All in all, I think looping through each command and
redoing the parameters is the best bet.

Good Luck

Bill
 
Back
Top