pb9 通過ole db連接sqlite3數(shù)據(jù)庫
sqlite3數(shù)據(jù)庫,簡單而功能強(qiáng)大,比起ini文件保存用戶設(shè)置,更簡單安全,為什么使用數(shù)據(jù)庫存用戶設(shè)置,由開發(fā)者自己去想吧
進(jìn)入話題:
pb中可以用ole DB方式在不注冊odbc的情況下直接連接數(shù)據(jù)庫,下面直接給出代碼,供有需要的參考
一、下載sqliteodbc.exe,具體下載位置,直接到網(wǎng)上搜索一下,其實只是需要里面的一個sqlite3odbc.dll這個文件
二、在PB中打開Database Profiles配置選項
Provider選擇MSDASQL
Extended Properties:Driver=SQLite3 ODBC Driver;Database=D:workSpacePBPenavicoqdcfg.db;PassWord=
注意在沒有安裝sqliteodbc的情況下,必須手工注冊SQLite3 ODBC Driver項值
如下圖
// Profile cfg
SQLCA.DBMS = "OLE DB"
SQLCA.AutoCommit = False
SQLCA.DBParm = "PROVIDER='MSDASQL',PROVIDERSTRING='Driver=SQLite3 ODBC Driver;Database=D:workSpacePBPenavicoqdcfg.db;PassWord='"
自動注冊SQLite3 ODBC Driver
public?function?boolean?pub_f_put_sysvar?(string?as_varcode,?any?aa_varvalue);//Public?function?pub_f_put_sysvar?(string?as_varcode,any?aa_varvalue)?returns?boolean? //string?as_varcode //any?aa_varvalue RETURN?pub_f_put_sysvar(as_varcode,aa_varvalue,TRUE) end?function public?function?boolean?of_regedit_driver?(string?as_path);//String?val[] String?val String?key key?=?"HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INISQLite3?ODBC?Driver" //if?RegistryGet(?"HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INI",?"SQLite3?ODBC?Driver",RegMultiString!,val)<>?1?then If?RegistryGet?(?key,?"Driver",? RegString!,?val?)?<>?1?Then if?RegistrySet(?key, ?"Driver",?RegString!,?as_path+"sqlite3odbc.dll")?<>?1?then?Return?False end?if If?RegistryGet?(?key,?"Setup",? RegString!,?val?)?<>?1?Then if?RegistrySet(?key,?"Setup",?RegString!,?as_path+"sqlite3odbc.dll")?<>?1?then?Return?False end?if //end?if Return?True end?function