Hi,

For those not familiar with LINQ, it's a new Microsoft feature in it's .NET languages that is supposed to allow developers to write querying language (i.e. SQL) code in the same format as the .NET language (e.g. C#.)

The .NET compiler will convert the code into a SQL statement - e.g. I code the following at design-time (in C#) for a simple database table called "config" containing "name" and "value" columns:

var q = from config where name == "test" select q;

.NET will compile this into the following SQL statement at run-time:

SELECT [t0].[name], [t0].[value] FROM [config] AS [t0] WHERE [t0].[name] = 'test';

The important thing to remember is that the generated SQL code cannot be viewed or edited at design time (AFAIK) so Johan's suggestion will be impossible to use, however he is right - the square brackets are the issue here.

A colleague of mine has a similar issue with the ASP.NET designer - when creating SQL statements in ASP.NET's front-end tools (e.g. data-grids) it automatically encloses the table names in [...] instead of `...`

Whether the MySQL .NET Connector people have already solved these issues, I don't know.

Andy


Johan Höök wrote:
Hi,
you're using Sqlserver syntax for handling reserved words.
In MySQL you use backtick` for the same, i.e.

select `t0`.`amount` etc.


/Johan



Sharique uddin Ahmed Farooqui skrev:
Hi,

I'm using VS Express 2008, and trying to use linq with Mysql.What I have done

   1. Created a db with a single table name account(fields : acct_num
int, amount int)
   2. created a Linqto sql file with same model as db table.
   3. A page with gridview and code behind is (on page load event):



MySqlConnection con = new
MySqlConnection(ConfigurationManager.ConnectionStrings["mysqltest"].ConnectionString);

MyLinqDataContext db = new MyLinqDataContext(con);

var q = from p in db.Accounts  p;

GridView1.DataSource = q;
GridView1.DataBind();

 I'm getting this error:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '[t0].[amount], [t0].[acct_num]
FROM [Account] AS [t0]' at line 1

I run  this query  in a mysql tool (HeidiSql), it gives same error. Is
it due to brackets '['  ?

 select [t0].[amount], [t0].[acct_num] FROM [Account] AS [t0]




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to