TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
leorio_psu
NA
1
0
Syntax for inserting a record on a MySql database
May 11 2006 3:37 AM
I got this problem on inserting a record to a certain database.
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'
Reply
Answers (
1
)
Handling large dataset
system error code