plz , can anyone help in this code ??
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
好像'缺少了
string sqlcon = "insert into images(imgname,imgpath)values('"+imagename+"','"+imagepath+"')";
There are two errors in your SQL-Statement:
The ' are missing.
Between the table(columns..) and VALUES the space is missing:
string sqlcon = "INSERT INTO images(imgname,imgpath) VALUES ('"+imagename+"','"+imagepath+"');";
Take a look at this: http://www.w3schools.com/sql/sql_insert.asp
It describes the INSERT INTO Statement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.