PB如何自动注册Mysql数据源
我现在有一个PB的程序,使用的是Mysql的数据库。
我现在要打包,谁知道pb如何自动注册mysql的数据源啊?
最好附上源码……
[解决办法]
string ls_local_path
string ls_user_path
string ls_local_path1
string ls_user_path1
string ls_install
string ls_instrans
ls_local_path ="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.ini\T3.1-UP"
ls_local_path1="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.ini\T3.1-DOWN"
ls_user_path ="HKEY_CURRENT_USER\Software\ODBC\ODBC.ini\T3.1-UP"
ls_user_path1="HKEY_CURRENT_USER\Software\ODBC\ODBC.ini\T3.1-DOWN"
//ls_local_path2="HKEY_USERS\S-1-5-21-3992001628-2338598895-2917826331-167080\Software\ODBC\ODBC.INI\ODBC Data Sources"
ls_install ="HKEY_CURRENT_MACHINE\Software\ODBC\ODBCINST.INI\Adaptive Server Anywhere 9.0"
ls_instrans ="HKEY_CURRENT_MACHINE\Software\ODBC\ODBCINST.INI\Adaptive Server Anywhere 9.0 Translator"
registryset(ls_install,"CPTimeout",regstring!,"<not pooled>")
registryset(ls_install,"Drivers",regstring!,gs_path+'dbma\dbodbc9.dll')
registryset(ls_install,"Setup",regstring!,gs_path+'dbma\dbodbc9.dll')
registryset(ls_instrans,"Drivers",regstring!,gs_path+'dbma\dbodbc9.dll')
registryset(ls_instrans,"Setup",regstring!,gs_path+'dbma\dbodbc9.dll')
ls_install ="HKEY_CURRENT_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers"
ls_instrans="HKEY_CURRENT_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Translators"
registryset(ls_install,'Adaptive Server Anywhere 9.0',regstring!,'Installed')
registryset(ls_instrans,'Adaptive Server Anywhere 9.0 Translator',regstring!,'Installed')
registryset(ls_local_path,"DataBaseFile",regstring!,gs_path+'\dbma\T3_up.db')
registryset(ls_local_path,"DataBaseName",regstring!,"T3_up")
registryset(ls_local_path,"Driver",regstring!,gs_path+'\dbma\dbodbc9.dll')
registryset(ls_local_path,"EngineName",regstring!,"T3-UP")
registryset(ls_local_path,"PWD",regstring!,"")
registryset(ls_local_path,"Start",regstring!,"")
registryset(ls_local_path,"UID",regstring!,"")
registryset(ls_user_path,"DataBaseFile",regstring!,gs_path+'\dbma\T3_up.db')
registryset(ls_user_path,"DataBaseName",regstring!,"T3_up")
registryset(ls_user_path,"Driver",regstring!,gs_path+'\dbma\dbodbc9.dll')
registryset(ls_user_path,"EngineName",regstring!,"T3-UP")
registryset(ls_user_path,"PWD",regstring!,"")
registryset(ls_user_path,"Start",regstring!,"")
registryset(ls_user_path,"UID",regstring!,"")
registryset(ls_local_path1,"AutoStop",regstring!,"Yes")
registryset(ls_local_path1,"CommLinks",regstring!,"ShareedMemory,TCPID{host=172.19.30.46}")
registryset(ls_local_path1,"Driver",regstring!,gs_path+'\dbma\dbodbc9.dll')
registryset(ls_local_path1,"EngineName",regstring!,"T3-DOWN")
registryset(ls_local_path1,"Compress",regstring!,"No")
registryset(ls_local_path1,"ConnectionName",regstring!,"yzzj")
registryset(ls_local_path1,"Debug",regstring!,"No")
registryset(ls_local_path1,"DisableMultiRowFetch",regstring!,"No")
registryset(ls_local_path1,"Integrated",regstring!,"No")
//
registryset(ls_user_path1,"AutoStop",regstring!,"Yes")
registryset(ls_user_path1,"CommLinks",regstring!,"ShareedMemory,TCPID{host=172.19.30.46}")
registryset(ls_local_path1,"Driver",regstring!,gs_path+'\dbma\dbodbc9.dll')
registryset(ls_user_path1,"EngineName",regstring!,"T3-DOWN")
registryset(ls_user_path1,"Compress",regstring!,"No")
registryset(ls_user_path1,"ConnectionName",regstring!,"yzzj")
registryset(ls_user_path1,"Debug",regstring!,"No")
registryset(ls_user_path1,"DisableMultiRowFetch",regstring!,"No")
registryset(ls_user_path1,"Integrated",regstring!,"No")
[解决办法]
最近刚好做了一个
//***********************************************
//函数名:gf_setodbc_mysql
// 功能:完成mysql数据源的注册功能
// 输入参数:
//as_server服务器名称
//as_database数据库名
//as_user用户名
//as_pwd密码
//返回值:
//true表示自动配置成功
//false表示自动配置失败
//设计者:Adamswater
// 完成时间:2010年03月
//***************************************************
booleanlb_rtn
stringls_root,ls_root_dsn,ls_root_Jet,ls_root_Engines
integerli_rtn
stringls_dsnname,ls_dbfullname,ls_driver,temp,ls_version
stringls_apppath
//
//integer rtn
//生成驱动程序所在路径gs_appdir为应用目录
ls_driver = gs_appdir + "myodbc5.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_database
//注册数据源的名字
li_rtn = registryset(ls_root,ls_dsnname,regstring!,"")
if li_rtn= - 1 then
return false
end if
//注册数据库名字
li_rtn = registryset(ls_root_dsn,"DATABASE",regstring!,ls_dbfullname)
if li_rtn= - 1 then
return false
end if
//注册数据库驱动程序
li_rtn = registryset(ls_root_dsn,"Driver",regstring!,ls_driver)//"C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.dll")//"C:\WINNT\system32\odbcjt32.dll")
if li_rtn= - 1 then
return false
end if
//注册端口号
li_rtn = registryset(ls_root_dsn,"PORT",regstring!,"3306")
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,"SERVER",regstring!,as_server)
if li_rtn= - 1 then
return false
end if
//注册数据库用户名
li_rtn = registryset(ls_root_dsn,"UID",regstring!,as_user)
if li_rtn= - 1 then
return false
end if
//注册数据库密码
li_rtn = registryset(ls_root_dsn,"PWD",regstring!,as_pwd)
if li_rtn= - 1 then
return false
end if
//OPTION
li_rtn = registryset(ls_root_dsn,"OPTION",regstring!,"4096")
if li_rtn= - 1 then
return false
end if
return lb_rtn