0

我正在尝试这样的事情:

        string pathFiles = Path.Combine(Application.StartupPath, "DB");
        string strconn = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;" +
               "Dbq="+pathFiles+";";                      
        OdbcConnection odbconn = new OdbcConnection(strconn);
        odbconn.Open();

我得到了这个例外

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

问题是相同的代码在windiws XP、visual studio 2010、office 2007 上运行正常,但在windows 7 64bit、visual studio 2008、office 2010 上运行不正常。我真的不知道有什么区别,我是新手赢得 7. 一些提示会很棒。谢谢。

4

1 回答 1

0

值得一提的是,我在 Vista 和 Windows 7 上使用以下连接操作 dBase 文件。我仍然将目标输出设置为 x86。

using (OleDbConnection connection = new OleDbConnection(string.Format("Provider=Microsoft.JET.OLEDB.4.0;" +
    "Data Source={0};Extended Properties=dBase IV;", Path.Combine(Environment.CurrentDirectory, OutputFolderName))))
{
    //....
    //....
}

输出文件夹名称只是我正在写入或读取的 DBase 文件所在的目录。

于 2010-09-03T19:18:01.150 回答