Calling access queries from .NET

  • Thread starter Thread starter Nick Gilbert
  • Start date Start date
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...
 
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...
 
¤ 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)
 
Back
Top