Questions about Prepare() method.

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
-----------------------------------
 
V

Val Mazur \(MVP\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top