开发者

Inserting a name into a MySql database via an ASP.net web Application

I am having a problem in inserting characters such as a name into a mySql database via an Asp.net application.

If I inserted numbers, the app adds the numbers into the database and I can see them, but the case with names, the name column in the database shows no values (kee开发者_运维技巧ps on showing null values) along with the numbers added.

command2 = New MySqlCommand("INSERT INTO customer(Customer_id, Customer_name) VALUES (@Customer_id, @Customer_name)", Connection) // Connection String

command2.Parameters.AddWithValue("@Customer_id", SqlDbType.Int).Value = TextBox1.Text()  //assign values

command2.Parameters.AddWithValue("@Customer_name", SqlDbType.VarChar).Value = TextBox2.Text()  //assign values

I appreciate it if you can help me with this

Regards, DoN


Try placing single quotes around @Customer_name:

command2 = New MySqlCommand("INSERT INTO customer(Customer_id, Customer_name) VALUES (@Customer_id, '@Customer_name')", Connection) // Connection String

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜