I’m getting this error in Visual Studio 2010 C# project. I used the Mysql driver version 6.8.3.0 to made the connection to mysql server(which created via mysql workbench 6.1) and the connection to mysql server established successful(which created via visual studio) but error comes in this line when my software runs. I search in the internet found that remote connection problem is the issue. But if my connection established fine this cannot be the issue and according to the error its saying that some issue in sql query. But this is a simple select statement(SELECT * FROM case).Any solution or suggestion is appreciated.
using (MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader())
in the following code section.
String connectionString = "server = localhost; user id = XXX; password = XXX; database = XXXX";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
String searchString = "SELECT * FROM case" ;
using (MySqlCommand mySqlCommand = new MySqlCommand(searchString, connection))
{
// mySqlCommand.Parameters.AddWithValue("@caseId", textBox1.Text);
using (MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader())
{
String sb;
sb = mySqlDataReader.GetInt32(0).ToString();
MessageBox.Show(sb);
The part of error i'm getting is this.
MySql.Data.MySqlClient.MySqlException was unhandled
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 'case' at line 1
Source=MySql.Data
ErrorCode=-2147467259 Number=1064 StackTrace:
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at CaseFinder.Form1.button1_Click(Object sender, EventArgs e) in