The solution could be in converting values to be able to save the data on the database.
Please help me on this one.
I use the following codes:
string t1; string sc;
t1=Textbox1.Text;
sc=2;
string ConnStr="Driver={MySQL ODBC 3.51 Driver};" + "Server=localhost;Database=tic";
OdbcConnection con=new OdbcConnection(ConnStr);
OdbcCommand cmd=new OdbcCommand("SELECT * FROM player",con);
con.Open();
OdbcDataReader MyDataReader;
MyDataReader=cmd.ExecuteReader();
cmd.CommandText="INSERT INTO player(name,score) VALUES("+t1+","+sc+")";
cmd.ExecuteNonQuery();
MyDataReader.Close();
con.Close();
whereas the value of t1 is 'lei' based from the value of Textbox1.
Error Message shows:
ERROR [42S21] [MySQL][ODBC 3.51 Driver][mysqld-4.0.16-nt]Unknown column 'lei' in 'field list'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.Odbc.OdbcException: ERROR [42S21] [MySQL][ODBC 3.51 Driver][mysqld-4.0.16-nt]Unknown column 'lei' in 'field list'
Robert LangstonPosted May 11, 2006, 5:50 AM
cmd.CommandText="INSERT INTO player(name,score) VALUES('"+t1+"','"+sc+"')";
or if score is marked as an integer in the database you dont need the single quotes around the sc.