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