C# 在数据库中插入图像
请告诉我,有人能帮上忙吗C# 在数据库中插入图像,c#,asp.net,sql,sql-server,C#,Asp.net,Sql,Sql Server,请告诉我,有人能帮上忙吗 string imagename="test.png"; string imagepath=Server.MapPath("\\images"); SqlConnection con = new SqlConnection(); SqlConnectionStringBuilder S = new SqlConnectionStringBuilder("data source=hima-pc\\sql8;initial c
string imagename="test.png";
string imagepath=Server.MapPath("\\images");
SqlConnection con = new SqlConnection();
SqlConnectionStringBuilder S = new SqlConnectionStringBuilder("data source=hima-pc\\sql8;initial catalog=test; integrated security= True;pooling=false ");
con.ConnectionString = S.ConnectionString;
con.Open();
string sqlcon = "insert into images(imgname,imgpath)values("+imagename+","+imagepath+")";
SqlCommand myCom = new SqlCommand(sqlcon,con);
int numrow = myCom.ExecuteNonQuery();
con.Close();
我需要在我的数据库中保存图像的路径
但是没有上传文件
我的图像已在服务器的文件夹中似乎“丢失了”
string sqlcon = "insert into images(imgname,imgpath)values('"+imagename+"','"+imagepath+"')";
SQL语句中有两个错误:
string sqlcon = "INSERT INTO images(imgname,imgpath) VALUES ('"+imagename+"','"+imagepath+"');";
它描述了INSERT INTO语句。问题是什么?你有错误吗?