Questions about Prepare() method.

  • Thread starter Thread starter Ken Varn
  • Start date Start date
K

Ken Varn

If I call the Prepare() method on a SqlCommand object, does it apply only to
that instance of the SqlCommand object or to the SqlConnection instance?

Also, I am assuming that Prepare() will aid in performance when calling the
same query multiple times. Is this true?

Finally, will Prepare() make any difference if I do not use parameters in
the command object, but instead embed the sql query into the command text
(i.e., select * from MyTable where MyVal = 123)?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
Hi Ken,

Prepare method prepares command for execution. Basically it checks syntax
and prepares all the parameters. When command prepared provider does not
spend anymore time to parse and check SQL statement. In a case if you do not
use parameters you probably get small advantage, but to see actual result I
would suggest to make an actual tests to see the difference.
 
Back
Top