pb 自动配置ODBC连接sql Anywhere

时间:2022-12-26 21:53:30

pb 自动配置ODBC连接sql Anywhere 2012-05-07 17:00:10

分类: Sybase

anywhere 11:
String ls_dbFile, ls_OrgID, ls_AppPath

ls_AppPath = Space(144)
if GetCurrentDirectoryA(144, ls_apppath)>0 then ls_apppath=trim(ls_apppath)

gs_apppath = ls_apppath
ls_dbfile=”.\DB*.db”
If Lower(ls_dbFile) = Lower(ls_AppPath + ‘\DB*.db’) Then Return

RegistrySet(gs_KeyODBC, ‘Autostop’, ‘Yes’)
RegistrySet(gs_KeyODBC, ‘DatabaseName’, ‘*’)
RegistrySet(gs_KeyODBC, ‘DatabaseFile’, ls_AppPath + ‘\DB*.db’)
RegistrySet(gs_KeyODBC, ‘UID’, ‘dba’)
RegistrySet(gs_KeyODBC, ‘PWD’, ‘sql’)
RegistrySet(gs_KeyODBC, ‘Driver’, ls_AppPath + ‘\DB\dbodbc11.dll’)
RegistrySet(gs_KeyODBC, ‘Start’, ls_AppPath + ‘\DB\dbeng11.exe -Q’)

其中:
global variables:
Constant String gs_KeyODBC = ‘HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.IN*’
global external functions:
Function ulong GetCurrentDirectoryA (ulong textlen, ref string dirtext) library “KERNEL32.DLL” alias for “GetCurrentDirectoryA;Ansi”
*代表数据源名称,#代表odbc名称.
当然,还必不可少相关动态库.