OleDB parameterized query for Access Database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bob

    OleDB parameterized query for Access Database

    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
  • Ignacio Machin ( .NET/ C# MVP )

    #2
    Re: OleDB parameterized query for Access Database

    On Apr 23, 11:55 pm, bob <startatbob_cl. ..@cutthis.adri ley.co.nz>
    wrote:
    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 :(

    Comment

    • bob

      #3
      Re: OleDB parameterized query for Access Database

      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

      On Thu, 24 Apr 2008 06:55:21 -0700 (PDT), "Ignacio Machin ( .NET/ C#
      MVP )" <ignacio.machin @gmail.comwrote :
      >On Apr 23, 11:55 pm, bob <startatbob_cl. ..@cutthis.adri ley.co.nz>
      >wrote:
      >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,
      >
      >Unfortunatel ly it's :(

      Comment

      Working...