c# 通过 OLEDB连接Access,DBF。


64位程序需要下载 驱动 AccessDatabaseEngine_X64.exe 

32位程序需要下载 驱动 AccessDatabaseEngine.exe 

官方下载地址:https://www.microsoft.com/zh-cn/download/details.aspx?id=13255

 

要与安装的office版本一直

64位链接

    this.connstring = string.Format("Provider = Microsoft.ACE.OLEDB.12.0 ;Data Source ={0};Extended Properties=dBASE IV;", filePath);
    this.Connection = new OleDbConnection(connstring);

32位链接

    this.connstring = string.Format("Provider = Microsoft.Jet.OLEDB.4.0 ;Data Source ={0};Extended Properties=dBASE IV;", filePath);
    this.Connection = new OleDbConnection(connstring);

基本代码

     this.Connection = new OleDbConnection(connstring);    
     OleDbCommand dc = Connection.CreateCommand();
    Connection.Open();
     dc.CommandText = Sql;
     int count = dc.ExecuteNonQuery();
     Connection.Close();
     dc.Dispose();

另外:Microsoft.ACE.OLEDB.12.0 可以访问正在打开的 Excel 文件,而 Microsoft.Jet.OLEDB.4.0 是不可以的。

更多链接字符串:https://www.connectionstrings.com/dbf-foxpro/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM