S
saqsaqPK
Guest
i am try to upload file and save path in database when submit the form show error
The SaveAs method is configured to require a rooted path, and the path
here is my code kindly advise us.
string imgfile = Path.GetFileName(FileImgesave.PostedFile.FileName);
FileImgesave.SaveAs("Images/" + imgfile);
SqlConnection connn = new SqlConnection(ConfigurationManager.ConnectionStrings["SECODMSConnectionString"].ConnectionString);
connn.Open();
string insertQuery = "insert tbl_Instrument_detail (tbl_customer_Id,tbl_Instrument_Id,tbl_Instrument_Serial,tbl_inst_install_date,tbl_Installed_Eng,tbl_upload_Installaion_doc)" +
" values (@CustomerID,@InstrumentID,@InstrumentSerial,@InstrumentInstallDate,@InstrumentInstalledEng,@ImgPath)";
SqlCommand com = new SqlCommand(insertQuery, connn);
com.Parameters.AddWithValue("@CustomerID", DropDownCustomer.SelectedValue);
com.Parameters.AddWithValue("@InstrumentID", DropDownInstrument.SelectedValue);
com.Parameters.AddWithValue("@InstrumentSerial", txtSerialNo.Text);
com.Parameters.AddWithValue("@InstrumentInstallDate", ASPxDateEd.Text);
com.Parameters.AddWithValue("@InstrumentInstalledEng", DropDownListEngineer.SelectedValue);
com.Parameters.AddWithValue("@ImgPath", "Images/" + imgfile);
com.ExecuteNonQuery();
Response.Redirect(Request.Url.AbsoluteUri);
connn.Close();
Continue reading...
The SaveAs method is configured to require a rooted path, and the path
here is my code kindly advise us.
string imgfile = Path.GetFileName(FileImgesave.PostedFile.FileName);
FileImgesave.SaveAs("Images/" + imgfile);
SqlConnection connn = new SqlConnection(ConfigurationManager.ConnectionStrings["SECODMSConnectionString"].ConnectionString);
connn.Open();
string insertQuery = "insert tbl_Instrument_detail (tbl_customer_Id,tbl_Instrument_Id,tbl_Instrument_Serial,tbl_inst_install_date,tbl_Installed_Eng,tbl_upload_Installaion_doc)" +
" values (@CustomerID,@InstrumentID,@InstrumentSerial,@InstrumentInstallDate,@InstrumentInstalledEng,@ImgPath)";
SqlCommand com = new SqlCommand(insertQuery, connn);
com.Parameters.AddWithValue("@CustomerID", DropDownCustomer.SelectedValue);
com.Parameters.AddWithValue("@InstrumentID", DropDownInstrument.SelectedValue);
com.Parameters.AddWithValue("@InstrumentSerial", txtSerialNo.Text);
com.Parameters.AddWithValue("@InstrumentInstallDate", ASPxDateEd.Text);
com.Parameters.AddWithValue("@InstrumentInstalledEng", DropDownListEngineer.SelectedValue);
com.Parameters.AddWithValue("@ImgPath", "Images/" + imgfile);
com.ExecuteNonQuery();
Response.Redirect(Request.Url.AbsoluteUri);
connn.Close();
Continue reading...