Powerbuilder编制的程序打包分为两部分 动态库文件及配置ODBC数据源
一动态库文件
由PB自带的打包工具:PowerBuilder Runtime Packager
在Database? Interfaces选项中选择
ODBC Database Driver(ODB)
Sybase Adaptive Server Enterprise(SYC)
便可生成程序所需要的动态库安装程序包然后将程序包中的文件复制到程序目录中即可
二配置ODBC在应用程序的Open事件中键入如下代码:
int RunCounts
RunCounts=profileint(TheOneRuniniRunFlagGetRunFlag)
string GetNowPath
GetNowPath = GetCurrentDirectory( )
String DataBasePath
DataBasePath=GetNowPath+\phonebook_databasedb
String DataBasePath_dll_DataBasePath_dll_
DataBasePath_dll_=GetNowPath+\dbodbcDLL
DataBasePath_dll_=GetNowPath+\dbengexe
if RunCounts= then
RegistrySet(HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINSTINI\ODBC DriversAdaptive Server Anywhere RegString!Installed)
RegistrySet(HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINSTINI\ODBC TranslatorsAdaptive Server Anywhere TranslatorRegString!Installed)
RegistrySet(HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINSTINI\Adaptive Server Anywhere DriverRegString!DataBasePath_dll_)
RegistrySet(HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINSTINI\Adaptive Server Anywhere SetupRegString!DataBasePath_dll_)
RegistrySet(HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINSTINI\ODBC Data Sources
phonebook_databaseRegString!Adaptive Server Anywhere )
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\odbc data sources
phonebook_databaseregstring!Adaptive Server Anywhere )
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
driverregstring!DataBasePath_dll_)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
startRegString!DataBasePath_dll_)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
uidregstring!dba)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
pwdregstring!sql)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
databasenameregstring!phonebook_database)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
databasefileregstring!DataBasePath)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
autostopregstring!yes)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
Integratedregstring!no)
registryset(HKEY_CURRENT_USER\software\odbc\odbcini\phonebook_database
Descriptionregstring!phonebook_database)
setprofilestring(TheOneRuniniRunFlagGetRunFlag)
end if
SQLCADBMS = ODBC
SQLCAAutoCommit =false
SQLCAdatabase=DataBasePath
SQLCADBParm = Connectstring=DSN=phonebook_database;uid=dba;pwd=sql
CONNECT USING SQLCA;
if sqlcasqlcode <> Then
messagebox(数据库连接失败请重启程序Question!Ok!)
setprofilestring(TheOneRuniniRunFlagGetRunFlag)
close(主窗体名)
Else
open(主窗体名)