設(shè)為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

VB或Access如何使用Sqlite數(shù)據(jù)庫的心得集錦

2015-5-18 11:31| 發(fā)布者: admin| 查看: 4749| 評論: 5|原作者: tmtony|來自: m.mzhfr.cn

摘要: 最近因客戶需要,要用到Sqlite數(shù)據(jù)庫,前端工具使用VB或Access, 在使用過程中遇到一些問題,(特別感謝 席主習(xí)_smileyoufu 幫助)通過網(wǎng)友幫助和網(wǎng)上搜索,將一些解決心得寫下來,希望對Sqlite入門者有所幫助和啟動(dòng) ...
最近因客戶需要,要用到Sqlite數(shù)據(jù)庫,前端工具使用VB或Access, 在使用過程中遇到一些問題,(特別感謝 席主習(xí)_smileyoufu 幫助)通過網(wǎng)友幫助和網(wǎng)上搜索,將一些解決心得寫下來,希望對Sqlite入門者有所幫助和啟動(dòng)
1.VB或Access 要直接使用Sqlite數(shù)據(jù)庫,需要安裝一個(gè)Sqlite litex的版本,才能正常注冊sqlite3.dll
    但實(shí)際我在注冊中,在一些電腦注冊會(huì)出現(xiàn)使用問題,網(wǎng)友如果測試成功,請跟貼
    sqlite lites使用說明及下載地址: http://blog.sina.com.cn/s/blog_48e2ea3401018fiz.html
2.可使用 sqliteforexcel 解決方案,里面封裝了一個(gè)dll  ,下載地址: http://sqliteforexcel.codeplex.com/
    SQLite3_StdCall.dll
    SQLiteForExcel.xls  
    SQLiteForExcel_64.xlsm
    SQLiteForWord.doc
    里面也包含
  • SQLite3_StdCall is a small and very simple C .dll that makes it possible to use the standard SQLite3 .dll from VBA. It just passes calls from VBA on to SQLite without any change in the parameters, but this allows the StdCall calling convention that VB6 and VBA is limited to.
  • Sqlite3.bas VBA module has all the VBA Declares, and does the parameter and string conversions. It exposes a number of SQLite3xxxx functions. These map as directly as possible to the SQLite C API, with no change in the semantics. Although I have not exposed the whole API, most of the core interface is included, in particular the prepared statement, binding, retrieval and backup functions. Date values are stored as Julian day real numbers in the database.
  • Sqlite3Demo.bas VBA module has tests that serve as nice examples of how to use the SQLite3xxxx functions.
  • SQLite3Demo.xls contains the two VBA modules.
  • 64-bit support for use with the 64-bit versions of Excel can be found in SQLiteForExcel_64.xlsm which has VBA code that supports both 32-bit and 64-bit versions of Excel. A 64-bit build of SQLite 3.7.13 is located in x64\SQLite3.dll. The corresponding Sqlite3Demo_64.bas module shows how to target both 32-bit and 64-bit Excel with the same VBA code (some #Ifs are required). (Note that the default install of Office is always the 32-bit version, even on a 64-bit version of Windows. Only if the 64-bit version of Office has been specifically selected will the 64-bit modules be required.)

      缺點(diǎn):是沒有創(chuàng)建新數(shù)據(jù)庫的方法,使用接口 與ado 不太兼容,語法不相同。遷移成本有點(diǎn)高

3. 第三種解決方案,也是   席主習(xí)_smileyoufu 提供方案,使用vbRichClient5.dll    vb_cairo_sqlite.dll   DirectCOM.dll
     可實(shí)現(xiàn)免注冊使用sqlite數(shù)據(jù)庫,且因?yàn)?vbRichClient5 的封裝,使用Sqlite數(shù)據(jù)庫幾乎 沒有太大的差異。
     且Sqlite的數(shù)據(jù)庫在一些性能性,特別的內(nèi)存數(shù)據(jù)庫,速度非常的快。對一些單機(jī)軟件非常適合
     使用方法,從 http://www.vbrichclient.com/ 官方下載
     vbRichClient5.dll    vb_cairo_sqlite.dll   DirectCOM.dll
     即可
     唯一缺點(diǎn)是發(fā)布時(shí)需要帶著  vbRichClient5.dll 庫(注冊或免注冊方式)
     vb_cairo_sqlite.dll (原生DLL,不需要注冊)   DirectCOM.dll
     且 vb_cairo_sqlite.dll   vbRichClient5.dll 必須保持在同一個(gè)目錄即可

相關(guān)鏈接:
Access數(shù)據(jù)庫與Sqlite數(shù)據(jù)庫性能對比測試
http://m.mzhfr.cn/thread-119912-1-1.html

發(fā)表評論

最新評論

引用 zpy2 2015-5-18 04:35
謝謝分享
引用 ganlinlao 2015-5-18 11:48
王站,什么時(shí)候轉(zhuǎn)向了?{:soso_e114:}

VB6使用SQLite的選項(xiàng)不多,而且或多或少有這樣那樣的問題。

1、litexSQlite,這是早期的比較牛的sqlite的com封裝。它牛到很多人想試圖修改它的源碼,但沒有一個(gè)能成功的。可見作者的c++功力是非常深厚的。
2、VBA版本的,確實(shí)讓人怎么用,怎么不習(xí)慣。這里面一個(gè)重要的原因是:大多數(shù)使用vba的人,如果不使用recordset,都不知道怎么使用數(shù)據(jù)庫里的數(shù)據(jù)。可以說recordset快等同于數(shù)據(jù)庫了。
3、sqlite有oledb的驅(qū)動(dòng)程序,這不是官方的,但它有一個(gè)糟糕的問題,必須注冊,雖然它是免費(fèi)使用,但使用者必須注冊。這一點(diǎn)太糟糕了,糟糕到好象蛋蛋被人捏著一樣的疼。
4、vbrichclient5。它的使用是沒有問題,問題在于如果你只用sqlite的話,那它的庫顯得有點(diǎn)龐大了一點(diǎn),因?yàn)槟悴挥盟钠渌δ,所以這樣的庫,就是一個(gè)胖客戶端。我也是建議大家使用vbrichclient5。
5、其實(shí)我很早就知道vbrichclient的作者,那時(shí)候,他根本就還沒寫vbrichclient。那時(shí),我也不知道他居然有這么大的雄心,會(huì)搞成這么大的框架。我在這里猶豫著要不要說,其實(shí)不用vbrichclient5,還可以使用更加小巧的適用vb使用的SQlite?偣膊500多K,而不是現(xiàn)在的5、6M這么大。只不過因?yàn)樗巡辉俦痪S護(hù)了,而且不是開源的,即使有問題,你也無從解決起。
如果我才這么猶豫著。




引用 tmtony 2015-5-18 11:53
冬瓜湯,原來你對Sqlite也有研究啊。
那個(gè)500K  的是什么DLL,使用方式是否像cRecordset一樣方便?
我現(xiàn)在是使用vbRichClient5.dll 使用還是比較方便,就是有點(diǎn)大,且免注冊方式在有些客戶電腦出關(guān)閉程序時(shí)出錯(cuò)。
我主要是解決一個(gè)客戶的問題。他要求用這個(gè)。一般開發(fā),我還是傾向于Access
引用 風(fēng)中漫步 2015-5-18 13:20
本帖最后由 風(fēng)中漫步 于 2015-5-18 13:23 編輯

{:soso_e121:}不好意思啊,站長.能說說您開發(fā)的這個(gè)庫用在哪方面嗎?昨天沒好意思問,如果不方便就別回了.
引用 tmtony 2015-5-18 13:30
1. 如果數(shù)據(jù)庫沒有修改,數(shù)據(jù)庫文件的日期不能改變
2. 大量需要不斷頻繁讀取服務(wù)器數(shù)據(jù)庫但數(shù)據(jù)并沒有經(jīng)常更新的場景,如單據(jù)中選擇產(chǎn)品資料,展示BOM等
3. 其它對數(shù)據(jù)速度有較高要求的

查看全部評論(5)

QQ|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2025-7-13 08:14 , Processed in 0.101792 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回頂部