Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

OleDB parameterized query for Access Database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bob - 24 Apr 2008 04:55 GMT
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
Scott M. - 24 Apr 2008 05:05 GMT
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
[quoted text clipped - 12 lines]
> Thanks
> Bob
bob - 24 Apr 2008 21:04 GMT
Hi Scott,
Thanks for your reply.
I'll leave the question marks in place to remind me that ordinal
position is important.
regards
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
[quoted text clipped - 18 lines]
>> Thanks
>> Bob
Ignacio Machin ( .NET/ C# MVP ) - 24 Apr 2008 14:55 GMT
On Apr 23, 11:55 pm, bob <startatbob_cl...@cutthis.adriley.co.nz>
wrote:
> Hi,
> Its been a long time since I have had the joy of feeding parameterized
[quoted text clipped - 12 lines]
> Thanks
> Bob

Hi,

Unfortunatelly it's :(
bob - 24 Apr 2008 21:08 GMT
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 Apr 23, 11:55 pm, bob <startatbob_cl...@cutthis.adriley.co.nz>
>wrote:
[quoted text clipped - 18 lines]
>
>Unfortunatelly it's :(

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.