Blueforcer Well-Known Member Licensed User Longtime User Jun 27, 2018 #1 Hello, i try to change some code from the jRDC. This works: Code: Copy Dim rs As ResultSet = con.ExecQuery("SELECT version, date FROM " & cmd.Parameters(0)) But this not: Code: Copy Dim rs As ResultSet = con.ExecQuery2(Main.rdcConnector1.GetCommand(cmd.Name), cmd.Parameters) with error: (MySQLSyntaxErrorException) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''wg'' at line 1 Click to expand... my logging tells me that the commands are correct: Code: Copy Log(Main.rdcConnector1.GetCommand(cmd.Name)& " param: " & cmd.Parameters(0)) SELECT version, date FROM ? param: wg Where i made the mistake?
Hello, i try to change some code from the jRDC. This works: Code: Copy Dim rs As ResultSet = con.ExecQuery("SELECT version, date FROM " & cmd.Parameters(0)) But this not: Code: Copy Dim rs As ResultSet = con.ExecQuery2(Main.rdcConnector1.GetCommand(cmd.Name), cmd.Parameters) with error: (MySQLSyntaxErrorException) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''wg'' at line 1 Click to expand... my logging tells me that the commands are correct: Code: Copy Log(Main.rdcConnector1.GetCommand(cmd.Name)& " param: " & cmd.Parameters(0)) SELECT version, date FROM ? param: wg Where i made the mistake?
OliverA Expert Licensed User Longtime User Jun 27, 2018 #2 Blueforcer said: Where i made the mistake? Click to expand... You cannot parameterize a table name in the FROM clause. That's using dynamic SQL, which is not supported by prepared statements/parameterized queries. If you are going that route (dynamic SQL), you really need to read this: http://www.sommarskog.se/dynamic_sql.html Upvote 0
Blueforcer said: Where i made the mistake? Click to expand... You cannot parameterize a table name in the FROM clause. That's using dynamic SQL, which is not supported by prepared statements/parameterized queries. If you are going that route (dynamic SQL), you really need to read this: http://www.sommarskog.se/dynamic_sql.html