用PB如何自动配置ODBC?
------解决方案--------------------
odbc多麻烦啊!
要是PB9的话就有专用接口,
pb10.5以上就用ole接口
不用再配置了!
------解决方案--------------------
//***********************************************
// 函数名: gf_setodbc_access
// 功能: 完成access数据源的注册功能
// 输入参数:
// as_database 数据库名
// (即Access数据库文件名字,不待扩展名)
// as_path 数据库文件所在的目录
// 返回值:
// true 表示自动配置成功
// false 表示自动配置失败
// 设计者: 魏远旺
// 完成时间: 2005年6月
//***************************************************
boolean lb_rtn
string ls_root,ls_root_dsn,ls_root_Jet,ls_root_Engines
integer li_rtn
string ls_dsnname,ls_dbfullname,ls_driver,temp,ls_version
string ls_syspath
integer rtn
ls_syspath = Space( 40 )
//获得操作系统的目录
GetSystemDirectoryA(ls_syspath,40)
ls_driver = ls_syspath + "\odbcjt32.dll"
lb_rtn = true
ls_root = "HKEY_LOCAL_MACHINE\software\odbc\odbc.ini"
//数据源名字为:文件名字+“_DT”
ls_dsnname = as_database + "_DT"
ls_root_dsn = ls_root + "\" + ls_dsnname
ls_root_Engines = ls_root_dsn + "\" + "Engines"
ls_root_Jet = ls_root_Engines + "\" + "Jet"
ls_dbfullname = as_path + "\" + as_database + ".mdb"
//注册数据源的名字
li_rtn = registryset(ls_root,ls_dsnname,regstring!,"")
if li_rtn= - 1 then
return false
end if
//注册数据库名字
li_rtn = registryset(ls_root_dsn,"DBQ",regstring!,ls_dbfullname)
if li_rtn= - 1 then
return false
end if
//注册数据库驱动程序
li_rtn = registryset(ls_root_dsn,"Driver",regstring!,ls_driver)//"C:\WINNT\system32\odbcjt32.dll")
if li_rtn= - 1 then
return false
end if
//注册其它项
li_rtn = registryset(ls_root_dsn,"FIL",regstring!,"MS Access;")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"Description",regstring!,"条形码打印程序")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"UID",regstring!,"")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"DriverId", RegULong!,25)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"SafeTransactions", RegULong!,0)
if li_rtn= - 1 then
return false
end if
//注册"Engines"项
li_rtn = registryset(ls_root_dsn,"Engines",regstring!,"")
if li_rtn= - 1 then
return false
end if
//注册"Jet"项
li_rtn = registryset(ls_root_Engines,"Jet",regstring!,"")
if li_rtn= - 1 then
return false
end if
//注册"Jet"项的各个子项
li_rtn = registryset(ls_root_Jet,"ImplicitCommitSync",regstring!,"")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"UserCommitSync",regstring!,"Yes")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"MaxBufferSize", RegULong!,2048)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"PageTimeout", RegULong!,5)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"Threads", RegULong!,3)
if li_rtn= - 1 then
return false
end if
return lb_rtn