Excelからデータベースにデータをアップロードするページを作成しましたが、サーバーではなくローカルシステムで正常に動作します。このエラーを修正するのを手伝ってください..これは私の部分的なコードです..
if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
{
path = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
SaveLocation = Server.MapPath("~/Temp") + "\\" + path;
path = "Temp/" + path;
FileUpload1.PostedFile.SaveAs(SaveLocation);
//Import from Excel to database
System.Data.OleDb.OleDbDataAdapter MyCommand = default(System.Data.OleDb.OleDbDataAdapter);
System.Data.OleDb.OleDbConnection MyConnection = default(System.Data.OleDb.OleDbConnection);
MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; " + "data source=" + SaveLocation + "; " + "Extended Properties=Excel 12.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
DS = new System.Data.DataSet();
MyCommand.Fill(DS);
DataTable dt = DS.Tables[0];
if (DS == null)
{
lblstatus.Text = "Problem occurred during uploading process... ";
}
else
{
foreach (DataRow row in dt.Rows)
{
DataSet5TableAdapters.sp_import_emp_generalTableAdapter TA = new DataSet5TableAdapters.sp_import_emp_generalTableAdapter();
TA.GetData(Convert.ToString(row["fldempid"]), Convert.ToString(row["fldlastname"]), Convert.ToString(row["fldfirstname"]), Convert.ToString(row["fldnickname"]),
Convert.ToString(row["fldDOB"]), Convert.ToString(row["fldmarital"]), Convert.ToString(row["fldgender"]), Convert.ToString(row["fldsmoker"]),
Convert.ToString(row["fldpic"]), Convert.ToString(row["fldaddress1"]), Convert.ToString(row["fldaddress2"]), Convert.ToString(row["fldcity"]),
Convert.ToString(row["fldstate"]), Convert.ToString(row["fldmobile"]), Convert.ToString(row["fldtele"]), Convert.ToString(row["fldwemail"]),
Convert.ToString(row["fldoemail"]), Convert.ToString(row["fldzip"]), Convert.ToString(row["fldtitle"]), Convert.ToString(row["fldjoindate"]),
Convert.ToString(row["fldspecification"]), Convert.ToString(row["fldcompany"]), Convert.ToString(row["fldgroup"]), Convert.ToString(row["flddept"]),
Convert.ToDouble(row["fldCTC"]), Convert.ToDouble(row["flddiv"]), Convert.ToDouble(row["fldbasic"]), Convert.ToDouble(row["fldhra"]),
Convert.ToDouble(row["fldconveyance"]), Convert.ToDouble(row["fldPF"]), Convert.ToDouble(row["fldesi"]), Convert.ToDouble(row["fldPT"]),
Convert.ToDouble(row["fldTDS"]), Convert.ToString(row["fldcafeteria"]), Convert.ToDouble(row["fldbasicvalue"]), Convert.ToDouble(row["fldhravalue"]),
Convert.ToDouble(row["fldconvalue"]), Convert.ToDouble(row["fldpfvalue"]), Convert.ToDouble(row["fldesivalue"]), Convert.ToDouble(row["fldptvalue"]),
Convert.ToDouble(row["fldtdsvalue"]), Convert.ToDouble(row["fldGrosspay"]), Convert.ToDouble(row["fldgrossearn"]), Convert.ToDouble(row["fldtotaldeduction"]),
Convert.ToDouble(row["fldnetpay"]), Convert.ToString(row["fldaccount"]), Convert.ToString(row["fldemployer"]), Convert.ToString(row["fldjobtitle"]),
Convert.ToString(row["fldstart"]), Convert.ToString(row["fldend"]), Convert.ToString(row["fldtotalexp"]), Convert.ToString(row["fldcomment"]),
Convert.ToString(row["fldedu"]), Convert.ToString(row["fldmajor"]), Convert.ToInt32(row["fldpassedout"]), Convert.ToString(row["fldskill"]),
Convert.ToString(row["fldexp"]), Convert.ToString(row["fldcomments"]), Convert.ToString(row["fldlanguage"]), Convert.ToString(row["fldfluency"]),
Convert.ToString(row["fldstatus"]));
}
System.Threading.Thread.Sleep(5000);
ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "<script language='javascript'>alert('Data Updated Successfully...');</script>", false);
lblstatus.Text = "Data updated successfully..";
}
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "<script language='javascript'>alert('Please select a file to upload');</script>", false);
}
}
catch (Exception e1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "<script language='javascript'>alert('" + e1.Message + "');</script>", false);
}
このエラーを修正するのを手伝ってください....