Issue with parameter

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
RJordan
Posts: 14
Joined: Tue 07 Nov 2006 11:45
Location: Germany

Issue with parameter

Post by RJordan » Thu 16 Nov 2006 11:02

I try a select command with the table as parameter:

...
mySqlSelectCommand1.CommandText = "select * from :Tablename";
mySqlSelectCommand1.Parameters.Add(new CoreLab.MySql.MySqlParameter("Tablename", CoreLab.MySql.MySqlType.VarChar));
mySqlSelectCommand1.Parameters["Tablename"].Value = "testreports";
...

The result on execution is the following error:
CoreLab.MySql.MySqlException wurde nicht von Benutzercode behandelt.
Message="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 ''testreports'' at line 1"

Source="CoreLab.MySql"
ErrorCode=-2147467259
Code=1064
...

The DBMonitors shows:
Execute: select * from :Tablename
Params:
Tablename Input VarChar testreports
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 ''testreports'' at line 1

Without using this parameter it works.

Anything special to do to use a parameter as the tablename? Or is it unpossible to use a parameter as tabelname?

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Thu 16 Nov 2006 12:32

It is impossible to use a parameter as a tablename.

Post Reply