Query Parameter prefix in Oledb

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a parametrized query based on City on the customers
table in Northwind.mdb. The sql version on Northwnd.mdf works fine using
@City in the query, but when I try to create it for the access dataset, it
puts single quotes around the '@City'. Is there another character one has to
use for access?

I am using Vb.net 2008

Thanks for any help,
Peter
 
peter,

This parametrized query works with Access:

cmd.CommandText = "Select * From Customers Where City = @City"
cmd.Parameters.AddWithValue("@City", myCity)

So does this one:

cmd.CommandText = "Select * From Customers Where City = ?"
cmd.Parameters.AddWithValue("@City", myCity)

And this one:

cmd.CommandText = "Select * From Customers Where City = ?"
cmd.Parameters.AddWithValue("City", myCity)

Kerry Moorman
 
Thank you Bill,
The ? worked perfectly. I was adding the ? along with the field name, but
just putting the ? did the job.

Also thanks to Kerry. The info came was very helpful.


Thanks again to both ,
Peter
 
Back
Top