Name Parameters - Access

G

Guest

Help!

I'm writing a vb.net application that uses Access as a database. I've got a
bunch of queries that I wrote within Access. I'm running them from VB. Most
of these queries have parameters. I'm adding parameters to an OleDbCommand
using Parameters.Add(name,value). This works fine as long as I add my
parameters in the same order as they exist in the Access query. I changed
"name" to something nonsensical and it still worked as long as the order was
correct. It doesn't seem to be matching the name. Oh, if the order isn't
correct, the vb app crashes.

Could someone tell me what I'm doing wrong?

Art
 
G

Guest

You're doing fine. Just OleDbParameter uses position instead of name. Your
program craches if you changed the order because the data types of the
parameters is different. Try to put three integer parameters and change the
order. I think it will work.
More information:
http://msdn.microsoft.com/library/d...rfsystemdataoledboledbparameterclasstopic.asp

and

http://msdn.microsoft.com/library/d...systemdatasqlclientsqlparameterclasstopic.asp

You can obviously see that OleDbParameter is different from SqlParameter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top