C# 如何把 编辑框内容和 图片二进制 一起存入数据库中的一张表里面 数据库是Sqlserver 感觉sql语句写错了
stringshijian=DateTime.Now.ToString("yyyy-MM-dd-hh:mm:ss");//时间SqlConnectionconn=newS...
string shijian = DateTime.Now.ToString("yyyy-MM-dd-hh:mm:ss"); //时间SqlConnection conn = new SqlConnection(mysql.sql); //连接 string cmd = "insert userstatic (name,fadanrenid,biaoti,xinxi,qq,dianhua,comboBox1,jiage,comboBox2,shijian) values (@image," + fadanrenid.Text + "','" + biaoti.Text + "','" + xinxi.Text + "','" + qq.Text + "','" + dianhua.Text + "','" + comboBox1.Text + "','" + jiage.Text + "','" + comboBox2.Text + "','" + shijian + "');'"; SqlCommand com = new SqlCommand(cmd, conn); com.Parameters.Add("@image", SqlDbType.Image).Value = File.ReadAllBytes(this.pictureBox1.ImageLocation); conn.Open(); if (com.ExecuteNonQuery() != 0) { MessageBox.Show("添加成功5秒后刷新数据", "提示"); }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询