Tag: 适配器

阅读打开的Excel文件时OleDBException

我有一个excel文件和一个oledb连接到它。 当在Windows打开文件时读取数据时,会引发以下错误(在Adapter.Fill方法中)。 但是,文件没有手动打开时,代码运行正常。 private System.Data.DataSet GetExcelData() { // Create new DataSet to hold information from the worksheet. System.Data.DataSet objDataset1 = new System.Data.DataSet(); DataTable dt = new DataTable(); try { string path = ConfigurationManager.AppSettings["ExcelFilePath"]; //string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;"; string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0 […]