I am having a syntax error when performing the following codeI was able to connect to the db server + performing select count(*) operation
Error 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 ')' at line 1 Native: 1064 Source: myodbc3.dll SQL: 23000)
.......................... string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=mydatabasename;" + "UID=myuid;" + "PASSWORD=mypass;" + "OPTION=3";
//Connect to MySQL using MyODBC OdbcConnection MyConnection = new OdbcConnection(MyConString); MyConnection.Open(); OdbcCommand MyCommand = new OdbcCommand("DROP TABLE IF EXISTS my_odbc_net",MyConnection); MyCommand.ExecuteNonQuery();
MyCommand.CommandText = "SELECT COUNT(*) as TRows FROM auth where UNAME = 'user01'"; //# rows string totalRows = " "+MyCommand.ExecuteScalar(); Response.Write("Number of output "+totalRows); Response.Write("<br>----------------------<br>"); MyCommand.CommandText = "SELECT * FROM auth WHERE IDCARDNO= 'user01')"; OdbcDataReader MyDataReader;MyDataReader = MyCommand.ExecuteReader(); // <======== Here comes the MySQL syntax error.
so if anybody had this problem and passed it or know how to solve it please reply me with the solution