[英]insert image in the database
plz , can anyone help in this code ?? PLZ,任何人都可以帮助这个代码?
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();
plz i need to save the path of image in my database but without uploadfile my image is already in the folder in server 我需要在我的数据库中保存图像的路径但没有uploadfile我的图像已经在服务器的文件夹中
好像'缺少了
string sqlcon = "insert into images(imgname,imgpath)values('"+imagename+"','"+imagepath+"')";
There are two errors in your SQL-Statement: 您的SQL语句中有两个错误:
The ' are missing. '失踪了。
Between the table(columns..) and VALUES the space is missing: 在表(列..)和VALUES之间缺少空格:
string sqlcon = "INSERT INTO images(imgname,imgpath) VALUES ('"+imagename+"','"+imagepath+"');";
Take a look at this: http://www.w3schools.com/sql/sql_insert.asp 看看这个: http : //www.w3schools.com/sql/sql_insert.asp
It describes the INSERT INTO Statement. 它描述了INSERT INTO语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.