C#调试错误“System.Data.OleDb.OleDbException”类型的未经处理的异常出现在 System.Data.dll 中。 5
我是想通过C#将一个已知的较大的Excel文件连接数据库进行输入操作,这段代码的BriGet.Fill(ds,"sheet1");处出现了错误,求大神指点:classIn...
我是想通过C#将一个已知的较大的Excel 文件连接数据库进行输入操作,这段代码的BriGet.Fill(ds,"sheet1");处出现了错误,求大神指点:
class InterfaceWork
{ public double[,] ReadInputData()
{string folder = "E:\\input.xls";
string strCon = @"Provider=Microsoft.Ace.OleDb.12.0;Data Source= " + folder + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=0';";
OleDbConnection ValExcel = new OleDbConnection(strCon);
ValExcel.Open();
string GetData = "select A,B,C,D,E,F,G,H,I,J,K,L from [sheet1$] order by id";
OleDbDataAdapter BriGet = new OleDbDataAdapter(GetData, ValExcel);
DataSet ds = new DataSet();
BriGet.Fill(ds,"sheet1");
DataTable dTable = ds.Tables[0];
ds.Dispose();
double[,] SaveData = new double[dTable.Rows.Count, 2];
for (int i = 0; i < dTable.Rows.Count; i++)
{
SaveData[i, 0] = Convert.ToInt16(dTable.Rows[i]['A']);
SaveData[i, 1] = Convert.ToInt16(dTable.Rows[i]['B']);
SaveData[i, 2] = Convert.ToInt16(dTable.Rows[i]['C']);
SaveData[i, 3] = Convert.ToInt16(dTable.Rows[i]['D']);
SaveData[i, 4] = Convert.ToInt16(dTable.Rows[i]['E']);
SaveData[i, 5] = Convert.ToInt16(dTable.Rows[i]['F']);
SaveData[i, 6] = Convert.ToInt16(dTable.Rows[i]['G']);
SaveData[i, 7] = Convert.ToInt16(dTable.Rows[i]['H']);
SaveData[i, 8] = Convert.ToInt16(dTable.Rows[i]['I']);
SaveData[i, 9] = Convert.ToInt16(dTable.Rows[i]['J']);
SaveData[i, 10] = Convert.ToInt16(dTable.Rows[i]['K']);
SaveData[i, 11] = Convert.ToInt16(dTable.Rows[i]['L']);
}
ValExcel.Close();
return SaveData;
}
“System.Data.OleDb.OleDbException”类型的未经处理的异常出现在 System.Data.dll 中。
其他信息: 至少一个参数没有被指定值。 展开
class InterfaceWork
{ public double[,] ReadInputData()
{string folder = "E:\\input.xls";
string strCon = @"Provider=Microsoft.Ace.OleDb.12.0;Data Source= " + folder + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=0';";
OleDbConnection ValExcel = new OleDbConnection(strCon);
ValExcel.Open();
string GetData = "select A,B,C,D,E,F,G,H,I,J,K,L from [sheet1$] order by id";
OleDbDataAdapter BriGet = new OleDbDataAdapter(GetData, ValExcel);
DataSet ds = new DataSet();
BriGet.Fill(ds,"sheet1");
DataTable dTable = ds.Tables[0];
ds.Dispose();
double[,] SaveData = new double[dTable.Rows.Count, 2];
for (int i = 0; i < dTable.Rows.Count; i++)
{
SaveData[i, 0] = Convert.ToInt16(dTable.Rows[i]['A']);
SaveData[i, 1] = Convert.ToInt16(dTable.Rows[i]['B']);
SaveData[i, 2] = Convert.ToInt16(dTable.Rows[i]['C']);
SaveData[i, 3] = Convert.ToInt16(dTable.Rows[i]['D']);
SaveData[i, 4] = Convert.ToInt16(dTable.Rows[i]['E']);
SaveData[i, 5] = Convert.ToInt16(dTable.Rows[i]['F']);
SaveData[i, 6] = Convert.ToInt16(dTable.Rows[i]['G']);
SaveData[i, 7] = Convert.ToInt16(dTable.Rows[i]['H']);
SaveData[i, 8] = Convert.ToInt16(dTable.Rows[i]['I']);
SaveData[i, 9] = Convert.ToInt16(dTable.Rows[i]['J']);
SaveData[i, 10] = Convert.ToInt16(dTable.Rows[i]['K']);
SaveData[i, 11] = Convert.ToInt16(dTable.Rows[i]['L']);
}
ValExcel.Close();
return SaveData;
}
“System.Data.OleDb.OleDbException”类型的未经处理的异常出现在 System.Data.dll 中。
其他信息: 至少一个参数没有被指定值。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询