简体   繁体   English

尝试将数据拉入C#时出现“找不到可安装的ISAM”错误

[英]“Cannot find installable ISAM” error when trying to pull data into C#

I'm currently working on an import from excel to c#, but this is the first time doing so, I thought I had the connection working after solving a number of other issues, but I am now receiving the above error. 我目前正在处理从excel到c#的导入,但这是第一次这样做,我认为在解决了许多其他问题后,我的连接已经开始工作,但是现在收到上述错误。

The code builds absolutely fine, and I can't find any other issues, anyone have any ideas? 代码构建得很好,我找不到任何其他问题,任何人都有想法吗?

using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_excel
{
class Program
{
    static void Main(string[] args)
    {
        // @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';"
        string con =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\Joshua.cameron\Documents\BullenGrosvenorTest\EstatesITExportSpec.xlsx';Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1;';";
// @"Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1'";
        using (OleDbConnection connection = new OleDbConnection(con))
        {
            connection.Open();
            OleDbCommand command = new OleDbCommand("select * from [Rental Sheet$]", connection);
            using (OleDbDataReader dr = command.ExecuteReader())
            {
                while (dr.Read())
                {
                    var row1ColA = dr[0];
                    Console.WriteLine(row1ColA);
                }
            }
        }
    }
}

} }

我可以通过将连接字符串修改为:

string con = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Joshua.cameron\Documents\BullenGrosvenorTest\EstatesITExportSpec.xlsx;Extended Properties='Excel 12.0 Xml;HDR=YES' ";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM