ADO.NET xxxConnection best practice

  • Thread starter Thread starter jeff
  • Start date Start date
J

jeff

hello

In my project i have classes whoes read,update , insert
database

for exemple in one method , i do 20 request

which is best the practice ?

a) open and close ADO.NET connection for each requests
(using pooling connection but slower cause of .open()
method ?)

or

b) open one connection for method , excute requests ,
close connection ( the pooling connection is use for the
project and calls methods but not in each methods )


rq: my question is NOT for Execute multi request on one
command , and NOT for using stored procedure
thanks
 
¤ hello
¤
¤ In my project i have classes whoes read,update , insert
¤ database
¤
¤ for exemple in one method , i do 20 request
¤
¤ which is best the practice ?
¤
¤ a) open and close ADO.NET connection for each requests
¤ (using pooling connection but slower cause of .open()
¤ method ?)
¤
¤ or
¤
¤ b) open one connection for method , excute requests ,
¤ close connection ( the pooling connection is use for the
¤ project and calls methods but not in each methods )
¤
¤
¤ rq: my question is NOT for Execute multi request on one
¤ command , and NOT for using stored procedure
¤ thanks

I see no reason to request a connection for each operation. If you have 20 inserts/updates, pass
them all into your method, request the connection, perform all of the updates/inserts and then
release the connection by closing it.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top