熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PB編程 >> 正文

Powerbuilder 10.0應用程序發布及動態配置ODBC

2022-06-13   來源: PB編程 

  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(主窗體名)
From:http://tw.wingwit.com/Article/program/PB/201311/24560.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.