Search code examples
c#visual-studio-2008parameterssyntax-errortableadapter

Paremeters in TableAdapter not accepted


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


Solution

  • 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.