Powerbuilder編制的程序打包分為兩部分 動態庫文件及配置ODBC數據源
一動態庫文件
由PB自帶的打包工具:PowerBuilder Runtime Packager
在Database? Interfaces選項中 選擇
ODBC Database Driver(ODB)
Sybase Adaptive Server Enterprise(SYC)
便可生成程序所需要的動態庫安裝程序包然後將程序包中的文件復制到程序目錄中即可
二配置ODBC在應用程序的Open事件中鍵入如下代碼:
int RunCounts
RunCounts=profileint(
TheOneRun
ini
RunFlag
GetRunFlag
)
string GetNowPath
GetNowPath = GetCurrentDirectory( )
String DataBasePath
DataBasePath=GetNowPath+
\phonebook_database
db
String DataBasePath_dll_
DataBasePath_dll_
DataBasePath_dll_
=GetNowPath+
\dbodbc
DLL
DataBasePath_dll_
=GetNowPath+
\dbeng
exe
if RunCounts=
then
RegistrySet(
HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST
INI\ODBC Drivers
Adaptive Server Anywhere
RegString!
Installed
)
RegistrySet(
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST
INI\ODBC Translators
Adaptive Server Anywhere
Translator
RegString!
Installed
)
RegistrySet(
HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST
INI\Adaptive Server Anywhere
Driver
RegString!
DataBasePath_dll_
)
RegistrySet(
HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST
INI\Adaptive Server Anywhere
Setup
RegString!
DataBasePath_dll_
)
RegistrySet(
HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST
INI\ODBC Data Sources
phonebook_database
RegString!
Adaptive Server Anywhere
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\odbc data sources
phonebook_database
regstring!
Adaptive Server Anywhere
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
driver
regstring!
DataBasePath_dll_
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
start
RegString!
DataBasePath_dll_
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
uid
regstring!
dba
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
pwd
regstring!
sql
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
databasename
regstring!
phonebook_database
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
databasefile
regstring!
DataBasePath)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
autostop
regstring!
yes
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
Integrated
regstring!
no
)
registryset(
HKEY_CURRENT_USER\software\odbc\odbc
ini\phonebook_database
Description
regstring!
phonebook_database
)
setprofilestring(
TheOneRun
ini
RunFlag
GetRunFlag
)
end if
SQLCA
DBMS =
ODBC
SQLCA
AutoCommit =false
SQLCA
database=DataBasePath
SQLCA
DBParm =
Connectstring=
DSN=phonebook_database;uid=dba;pwd=sql
CONNECT USING SQLCA;
if sqlca
sqlcode <>
Then
messagebox(
數據庫連接失敗
請重啟程序
Question!
Ok!)
setprofilestring(
TheOneRun
ini
RunFlag
GetRunFlag
)
close(主窗體名)
Else
open(主窗體名)
From:http://tw.wingwit.com/Article/program/PB/201311/24560.html