The Prepare function is a throwback to the ODBC drivers that needed this to
tell the interface to "prepare" the SQL for execution. It's not needed in
ADO.NET and as far as I can tell (although my experiments aren't complete on
2.0) it does nothing (it's a noop) in the SqlClient provider.
If you want to build parameter queries you can, but it has nothing to do
with Prepare. Try building a Command object and set the Command text to
include named parameter markers
SELECT Author FROM Authors WHERE au_id = @idwanted
Next, setup a Parameters collection on the Command to manage the Parameter
cmd.Parameters.AddWithValue("@idwanted",15)
and execute.
I discuss this in my ADO.NET book (on the shelves now). While it does not
cover 2.0 it does cover these basics.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________