0
我試圖將圖像存儲在我的ASP.NET Web表單網站的'Images'文件夾中。System.Data.SqlClient.SqlException'發生了
這背後是我的提交按鈕的代碼:
protected void btnSubmit_Click(object sender, EventArgs e)
{
//Get Filename from fileupload control
string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName);
//Save images into Images folder
fileuploadimages.SaveAs(Server.MapPath("Images/" + filename));
//Getting dbconnection from web.config connectionstring
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BallinoraDBConnectionString1"].ToString());
//Open the database connection
con.Open();
//Query to insert images path and name into database
SqlCommand cmd = new SqlCommand("Insert into Group_Images(ImageName,ImagePath) values(@ImageName,@ImagePath)", con);
//Passing parameters to query
cmd.Parameters.AddWithValue("@ImageName", filename);
cmd.Parameters.AddWithValue("@ImagePath", "Images/" + filename);
cmd.ExecuteNonQuery();
//Close dbconnection
con.Close();
Response.Redirect("~/Admin.aspx");
}
Here is the error message I'm receiving
表結構沒有進入崗位。你可以添加它嗎?謝謝:) – scsimon
嘗試閱讀錯誤消息。 – SLaks
@scsimon忘記了添加鏈接!謝謝。 – user2911539