TableAdapter Parameterized Query (Access DB)

How can I add a parameterized Access query to a TableAdapter.

For SQL Server I could simply say

SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax

FROM dbo.Customers

WHERE ContactName LIKE @ContactName

But it doesn’t work in case of access db. complains about @ ?

[1140 byte] By [JobLot] at [2007-12-16]
# 1
Hello,

Access uses a ? as the parameter placeholder (SQL Server uses named parameters prefixed with the @ symbol)

So the query would look like this:
SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax
FROM Customers
WHERE (ContactName LIKE ?)
Hope that helps,

SteveS_MS at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
what if i need more than one parameter, would they both have '?'

say for instance

SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax
FROM Customers
WHERE ContactName LIKE ? AND PostalCode = ?

How would they be differentiated?

JobLot at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

When you create the TableAdapter query the method signature will actually use the column names that are in the WHERE clause and differentiate for you. For your example the TableAdapter query would look like:

CustomersTableAdapter.Fillby(ContactName, PostalCode)
Basically, unnamed parameters need to be passed in in the same order as they appear in the query.
Hope that helps!

SteveS_MS at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...