mysql图像没有插入asp.net C# [英] Mysql image not inserting in asp.net C#
本文介绍了mysql图像没有插入asp.net C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void submitbtn_Click(object sender, EventArgs e)
{
byte[] image = null;
if (FileUpload1.HasFile)
{
int length = FileUpload1.PostedFile.ContentLength;
image = new byte[length];
HttpPostedFile img = FileUpload1.PostedFile;
img.InputStream.Read(image, 0, length);
}
string query = "Insert into pro(product,prname,prdes,key,price,image) values ('"+selec+"','"+prnametxt.Text+"','"+prdestxt.Text+"','"+keytxt.Text+"','"+pricetxt.Text+"',@imgs)";
MySqlCommand cmd = new MySqlCommand(query, con);
cmd.Parameters.AddWithValue("@imgs", image);
cmd.ExecuteNonQuery();
}
Insering我收到此错误
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在密钥,价格,图像值附近使用正确的语法('','管理员','管理员','管理员','44','System.Byte [ ]')'第1行
推荐答案
Key是MySql中的保留关键字,因此它没有插入
"Key" is an reserved keyword in the MySql so it did't get insert
这篇关于mysql图像没有插入asp.net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文