c# - 有没有办法在 c# 中为 Oledb 找到异常详细信息?
问题描述
它工作正常,直到“ oleda.Fill(ds);”行 当调试器到达该行时,它不会显示任何错误或异常,只是返回到视图(HTML 页面)。我无法理解异常的来源。任何人都可以请指导我。
public class OledbRepository
{
private string _connectionString;
public OledbRepository(string filePath)
{
_connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';";
}
public DataTable Invoke(string sheetName)
{
DataTable result;
using (var connection = new OleDbConnection(_connectionString))
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM " + sheetName, connection);
OleDbDataAdapter oleda = new OleDbDataAdapter() { SelectCommand = cmd };
DataSet ds = new DataSet();
oleda.Fill(ds);
result = ds.Tables[0];
}
return result;
}
}
解决方案
推荐阅读
- amazon-web-services - 如何处理关系数据库中的 AWS IOT 流数据
- java - 打印 ByteArrayOutputStream 对象
- ios - 如何在 XCode 9.3 上收集覆盖率数据?
- python - 在 python 中转换 strptime 中的数据时出现问题
- c# - 从 SQLite 数据库绑定 ListView 图像,Xamarin 表单
- c# - Excel 导出在 c# 中的其他语言没有正确输出
- apdu - EMV - 带有 PDOL 的 GPO
- angular - 在Angular 5中使用`符号进行连接
- java - 如何基于列合并两个数据框 spark java/scala?
- javascript - 如何从jsp中找到安装程序路径?