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.
__________________________________
"Patrick McGovern" <(E-Mail Removed)> wrote in message
news:dcbdt7$587$(E-Mail Removed)...
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Do you mean the "Prepare" method on the (Sql)Command class? I'm
>> documenting that this week.
>
> that's exactly what i mean!
this is the functionality that allows me to
> write a statement like "select * from project where id=?" right?
>
>>
>> --
>> ____________________________________
>> 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.
>> __________________________________
>>
>> "5By5" <(E-Mail Removed)> wrote in message
>> news:dc95fe$g5f$(E-Mail Removed)...
>>> Hi all,
>>>
>>> Can someone point me to an example of prepared statements being used in
>>> C# ado.net? the MSDN site has examples using VB and my documentation in
>>> VS 2005 says "to be filled in" or something equally useful.
>>>
>>> thanks in advance,
>>> Pat
>>>
>>
>>
>
>