SQLCommand.Prepare

  • Thread starter Thread starter John A Grandy
  • Start date Start date
J

John A Grandy

under what circumstances would one want to make a call to
SQLCommand.Prepare() ?

what exactly does it accomplish ?
 
under what circumstances would one want to make a call to
SQLCommand.Prepare() ?

what exactly does it accomplish ?

As I understand it, preparing a statement basically does a lot of the
parsing, validation etc (either on the client side or on the server
side, depending on the database and driver) so that the statement can
be executed several times with different parameters efficiently.
Typical use case (again, as I understand it):

Create the command
Add parameters (the placeholders)
Prepare the command

In a loop:
Set parameter values
Execute command
 
Back
Top