0

In Visual Studio 2010, I am using the wizard to create queries for TableAdapters. The query SELECT Modell FROM BHKW WHERE Energieträger = @Energieträger causes "Error around @ character" to appear (within the wizard). And this event though

  1. the @ and ä characters are allowed characters and
  2. this very simple query comes from an official Microsoft example (only the field names have been changed).

Does anybody know how to solve this problem?

Community
  • 1
  • 1
Nicolas
  • 1,151
  • 3
  • 15
  • 28
  • What is the error? And what does you code look like? try removing the ä. It maybe allowed in TSQL, but probably isn't in C# (or VB whatever you're using) – Gerald Versluis Aug 14 '12 at 09:09
  • The error does not come from the `ä`. I also tried an equivalent query `SELECT Modell FROM BHKW WHERE Hersteller = @Hersteller` that gave me the same error. – Nicolas Aug 14 '12 at 09:19
  • The error (translated) is "The assistant encountered the following error with your query: SELECT-Instruction has been generated. Error in the WHERE clause in the proximity of "@". Analysis of the query text impossible." I would tend to say that the error is independent from my code, as it happened into the wizard and not by compiling. – Nicolas Aug 14 '12 at 09:25

1 Answers1

1

The wizard requires the use of square brackets for a SQL database. The correct query is then the following:

SELECT Modell FROM BHKW WHERE Energieträger = [@Energieträger]

If you use an Access database, the wizard will complete successfully but a warning will pop-up: "Returned data does not conform to the table's schema."

The correct syntax with an Access database requires a question mark:

SELECT Modell FROM BHKW WHERE (Energieträger = ?)
Nicolas
  • 1,151
  • 3
  • 15
  • 28