Calling access queries from .NET

N

Nick Gilbert

Hi,

I'm trying to call a query I have in my access database from .NET. The
query is called "UpdateAddress".

So I'm calling it like this:

cmd = new OleDbCommand();
cmd.Connection = this.Connection;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OleDbParameter("Town",OleDbType.Integer)).Value =
town;
cmd.ExecuteNonQuery();

The problem is, the query doesn't seem to care about the name of the
parameter. I can change the word "Town" to be "foobar" and it still
updates the town with no errors. The problem comes when I add lots of
extra fields to update - without names working it just creates a mess.

Does Access not support named parameters like SQL Server does? How else
can I reliably pass 10 paramenters to an Access query from .NET?

Thanks,

Nick...
 
N

Nick Gilbert

PS
I've worked out that it only seems to care about the ORDER that the
parameters are passed in in. It does not use the names of the parameters
at all. Is this normal for Access or have I done something wrong in my
database or code?

Thanks,

Nick...
 
P

Paul Clement

¤ PS
¤ I've worked out that it only seems to care about the ORDER that the
¤ parameters are passed in in. It does not use the names of the parameters
¤ at all. Is this normal for Access or have I done something wrong in my
¤ database or code?
¤

Actually it's a function (unsupported) of OLEDB. Parameter names are ignored and order takes
precedence.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

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