I am writing a very simple bit of code and cannot figure out why the parameters are not working on my SQL select. Any advice would be appreciated.
- I have a prior connection/select without parameters that works fine
- I have tried the select in MySQL workbench it is fine (and have simplified it too) Here is the relevant code. There is an exception on the ExecuteReader statement.
This is the result from the locals window:
- [MySql.Data.MySqlClient.MySqlException] {"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 ''AAIT_N'' at line 1"} MySql.Data.MySqlClient.MySqlException
MySqlConnection conn = new MySqlConnection(connString);
MySqlCommand cmd;
conn.Open();
try
{
cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * from @p ";
cmd.Parameters.AddWithValue("@p", sym);
string wait = Console.ReadLine();
MySqlDataReader myresults = cmd.ExecuteReader(); <=== Throws an exception
if (myresults.HasRows)
etc.