Power Builder同时连接多个数据库

王朝other·作者佚名  2007-07-12
宽屏版  字体: |||超大  

Power Builder同时连接多个数据库

赵韶平

只 需 设 置 两 个 TRANSACTION对 象 即 可 。

以 下 为 同 时 连 接 SQL SERVER和 DBF数 据 库 的 示 例 :

连 接 SQL SERVER:

SetPointer(HourGlass!)

//窗 口 居 中

f_center(this)

//根 据 sgselect 连 接 不 同 的 套

string sSelect

string temp

sSelect="d_gdzc"+sgselect

SQLCA.DbParm = ProfileString(gzINIFile,"Database","DbParm","")

SQLCA.DBMS = ProfileString(gzINIFile,"Database","DBMS","")

SQLCA.Database = sSelect

SQLCA.ServerName = ProfileString(gzINIFile,"Database","ServerName","")

SQLCA.LogId = "sa"

RegistryGet("HKEY_CURRENT_USER\software\microsoft\windows\currentversion\explorer\g", "a", RegString!,temp )

f_anencrypt (temp,SQLCA.LogPass)

SQLCA.AutoCommit = false

SQLCA.Lock = ProfileString(gzINIFile,"Database","Lock","")

connect using sqlca;

IF SQLCA.SQLCode <> 0 THEN

MessageBox("联 接 失 败 ", &

"不 能 联 接 数 据 库 !(错 误 信 息 :" + SQLCA.SQLErrText+")")

setpointer(Arrow!)

RETURN

halt close

END IF

定 义 函 数 :

fuction f_connectdbf(string sdbparm) return any

string nul //用 于 生 成 null值

transaction trans_name

trans_name=create transaction

trans_name.DBMS = "ODBC"

//trans_name.Database = "ZWDBF"

//trans_name.LogId =

//trans_name.LogPass =

trans_name.AutoCommit = False

trans_name.DBParm = sDBParm

//trans_name.Lock =ProfileString(gzINIFile,"Database","Lock","")

//trans_name.DbParm =ProfileString(gzINIFile,"Database","DbParm","")

CONNECT USING trans_name;

IF trans_name.SQLCode <> 0 THEN

MessageBox("联 接 失 败 ", &

"不 能 联 接 财 务 数 据 库 ! 请 检 查 财 务 路 径 是 否 正 确 。 (错 误 信 息 :" + SQLCA.SQLErrText+")")

rollback;

return setnull(nul)

else

return trans_name

END IF

连 接 FOXPRO数 据 库 ( 同 时 连 接 第 二 个 数 据 库 , 还 可 以 连 接 第 三 、 第 四 个 ) :

openwithparm(w_disp,"正 在 联 接 DBF卡 片 数 据 库 ...",parent)

transaction sqldbf

//用 SQLDBF连 接 财 务 ( 固 资 ) 数 据 库

sqldbf=f_connectdbf("Connectstring='DSN=gzdbf'")

//判 断 是 否 联 接 成 功

if isnull(sqldbf) then

Messagebox("出 错 ","联 接 DBF固 定 资 产 数 据 库 出 错 ! ")

end if

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有