我想绑定我的图像控制与SQL数据库。我节省了SQL数据库我的图片路径,我来自database.When检索图片的路径我检查通过断点那么它显示我的图像的路径,但画面没有在这里结合是我的代码图像没有约束力
string imagepath = Server.MapPath("~/Pics/");
string serverfilename = Path.GetFileName(AsyncFileUpload1.PostedFile.FileName);
string fullpath = Path.Combine(imagepath, serverfilename);
string path = "~\\Pics\\" + serverfilename;
//string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
//string path = Server.MapPath("~/Pics/") + filename;
AsyncFileUpload1.SaveAs(fullpath);
// FileUpload1.PostedFile.SaveAs(path);
SqlCommand cmd = new SqlCommand("insert findfriend values('" + path + "','" + TextBox1.Text + "')", con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
SqlCommand GetImage = new SqlCommand("select * from findfriend where name='" + TextBox1.Text + "'", con);
GetImage.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(GetImage);
DataSet ds = new DataSet();
da.Fill(ds);
Image1.ImageUrl = ds.Tables[0].Rows[0][1].ToString();
请告诉我我在哪里做错了
服务器响应错误:“未知服务器错误” 我得到这个错误,当我做我的 –
图像被成功地上传,它是存在于目录太 –
调试和打印ds.Tables的值[0] .Rows [0] [1]的ToString();并看看它是否正确路径 –