Paremeters in TableAdapter not accepted

2019-07-05 03:37发布

问题:

I'm currently trying to set up my TableAdapters, but it doesn't allow me to use parameters (what makes it quite useless) - When I create a new Query

SELECT     users.*
FROM         users
WHERE name LIKE @name

It tells me there is a SQL-Error near '@'...

I'm using VS08 with C# and an Access-Database using OleDB-Driver

回答1:

Look here:

How to: Create Parameterized TableAdapter Queries

When constructing a parameterized query, use the parameter notation specific to the database you are coding against. For example, Access and OleDb data sources use the question mark '?' to denote parameters, so the WHERE clause would look like this: WHERE City = ?.

Try to substitute @ with ? and see if your query compiles.