国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

自動注冊Access ODBC

2024-07-21 02:09:36
字體:
供稿:網(wǎng)友

看到網(wǎng)上有好多的程序都提供這項(xiàng)服務(wù),但我不喜歡彈出式窗口和復(fù)雜的過程調(diào)用。
自已翻翻注冊表,就想到了只通過鍵值來注冊的方法。當(dāng)然前提是你需要先測試此數(shù)據(jù)庫是否可以使用。
ulong function uf_regodbc(string odbcname,string filename,int flag)

//根據(jù)mdb文件名和odbc dsn名建一個(gè)odbc數(shù)據(jù)據(jù)源
// flag =1 修改原數(shù)據(jù)據(jù)源
//falg=0 新建數(shù)據(jù)源
string driverfile
string uid
setnull(uid)
string cdirect
cdirect=getcurrentdirectory()
if right(cdirect ,1)<>'/' then cdirect=cdirect+"/"
if (odbcname='') or(filename='') then
 messagebox("信息","建立或修改數(shù)據(jù)源時(shí)文件名或數(shù)據(jù)源名不能為空!")
 return -1
end if

if not fileexists(filename) then
 messagebox("信息",'數(shù)據(jù)源注冊或修改失敗,請正確填寫文件名!')
 return -1
end if
if not fileexists(getsystemroot()+"system32/odbcjt32.dll") then
 filecopy(cdirect+"/mytool/odbcjt32.dll",getsystemroot()+"system32/odbcjt32.dll",true)
end if
driverfile=getsystemroot()+"system32/odbcjt32.dll"
 


if flag=0 then
 //新建數(shù)據(jù)源
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"dbq",regstring!,filename)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"driver",regstring!,driverfile)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"driverid",regulong!,25)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"fil",regstring!,"ms access;")
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"safetransactions",regulong!,0)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"uid",regstring!,"")
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname+"/engines/jet","implicitcommitsync",regstring!,"")
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname+"/engines/jet","maxbuffersize",regulong!,2048)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname+"/engines/jet","pagetimeout",regulong!,5)
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname+"/engines/jet","usercommitsync",regstring!,'yes')
else
 registryset("hkey_current_user oftware/odbc/odbc.ini/"+odbcname,"dbq",regstring!,filename)
 
end if
registryset("hkey_current_user oftware/odbc/odbc.ini/odbc data sources",odbcname,regstring!,"microsoft access driver (*.mdb)")

當(dāng)然,如果數(shù)據(jù)庫有用戶名和密碼就需要你再寫倆鍵值了。類推的。asa庫的注冊也是一樣的。網(wǎng)上也有很多。不再祥敘。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 潞西市| 四会市| 岑巩县| 调兵山市| 汝阳县| 鹤岗市| 远安县| 合川市| 马尔康县| 修水县| 保德县| 乌兰浩特市| 额敏县| 浦江县| 海林市| 灵丘县| 连平县| 东丰县| 石门县| 通江县| 汽车| 深州市| 囊谦县| 含山县| 怀远县| 清远市| 清河县| 冷水江市| 聂拉木县| 同江市| 益阳市| 曲靖市| 延吉市| 长丰县| 集贤县| 和龙市| 丰顺县| 嵊州市| 正镶白旗| 凉城县| 那曲县|