OleDB parameterized query for Access Database

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hi,
Its been a long time since I have had the joy of feeding parameterized
query CommandText strings to an OleDBCommand object.
I have tried all manner of versions of " update foo set bar = @bar
where id = @id"
I have wrapped the fields in square brackets and the parameters in
square brackets and all manner of other strange variations.
The ExecuteNonQuery fires but the table doesn't update.

Finally went back to the old standby of ? as parameter place holder
and relying on Parameters ordinal position in the collection.

Is it really still this primitive or am I just screwing up the syntax?

Thanks
Bob
 
With Access and OleDB Providers you can use either the ? or the @, but the
parameters MUST be added to the command's parameters collection in the same
order that they are referenced in the update statement.

-Scott
 
Hi,
Its been a long time since I have had the joy of feeding parameterized
query CommandText strings to an  OleDBCommand object.
I have tried all manner of versions of  " update foo set bar = @bar
where id = @id"
I have wrapped the fields in square brackets and the parameters in
square brackets and all manner of other strange variations.
The ExecuteNonQuery fires but the table doesn't update.

Finally went back to the old standby of ? as parameter place holder
and relying on Parameters ordinal position in the collection.

Is it really still this primitive or am I just screwing up the syntax?

Thanks
Bob

Hi,

Unfortunatelly it's :(
 
Hi Scott,
Thanks for your reply.
I'll leave the question marks in place to remind me that ordinal
position is important.
regards
Bob
 
Hi Ignacio,
Thanks for your reply.
Scott says you can actually use named parameters but yes ordinal
position must be watched. I am going to stick with the question marks
so I don't fall for the same trap again.
regards
Bob
 
Back
Top