我开发了一个 ASP.NET 网站,它上传 Excel 文件并将其数据放入数据库。这在我的系统上完美运行,但是当我在服务器上运行它时,它失败了。我没有收到任何错误消息。"Server Error in '/' Application."
当我上传 Excel 文件时,页面显示错误。文件名到达上传文件夹。其名称已输入数据库,但数据失败。提前致谢。
显示错误的代码:
string excelConnectionString = "provider=Microsoft.jet.oledb.4.0;data source=" + xlspath + ";extended properties='Excel 8.0;HDR=YES;'";
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
excelConnection.Open();
OleDbCommand ocmd = new OleDbCommand("Select * from [sheet$]", excelConnection);
OleDbDataReader odr = ocmd.ExecuteReader();
string name = FileUpload1.FileName;
string Customer = "";
string DPS = "";
string FSC = "";
string FFSC = "";
string FFSR = "";
string DPC = "";
string RAG = "";
string Comments = "";
while (odr.Read())
{
Customer = valid(odr, 0);
DPS = valid(odr, 1);
FSC = valid(odr, 2);
FFSC = valid(odr, 3);
FFSR = valid(odr, 4);
DPC = valid(odr, 5);
RAG = valid(odr, 6);
Comments = valid(odr, 7);
insertdataintosql(name, Customer, DPS, FSC, FFSC, FFSR, DPC, RAG, Comments);
}
excelConnection.Close();
Label2.Text = "File Uploaded Sucessfully";
Label2.Visible = true;