Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用c#操作.dbf文件?_C#_.net_Odbc_Dbf - Fatal编程技术网

如何使用c#操作.dbf文件?

如何使用c#操作.dbf文件?,c#,.net,odbc,dbf,C#,.net,Odbc,Dbf,我正在尝试这样做: string pathFiles = Path.Combine(Application.StartupPath, "DB"); string strconn = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;" + "Dbq="+pathFiles+";"; OdbcConnection odb

我正在尝试这样做:

        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 64位、visual studio 2008、office 2010上不起作用。 我真的不知道有什么区别,我刚刚赢得7分。
一些提示会很好。谢谢。

我在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文件所在的目录。

是Windows 7机器的64位吗?是的,Windows 7是64位要跟进w/Mike的评论,您可能会检查一下,如果您将项目目标platorm build设置从任何CPU设置为x86,您是否会得到不同的行为。在64位平台上不存在某些db驱动程序。是的,这就是问题所在,我将平台目标更改为x86,它可以工作,但我想知道这是否是最好的方法。我们有很多产品是以这种方式部署的,因为项目中的依赖性,例如64位平台上不存在/安装的驱动程序。对我们来说,这是完成任务的最佳方式,直到我们有时间用其他东西替换这些依赖关系。