在pb里可以同时连接两个数据库么

在pb里可以同时连接两个数据库么,第1张

可以的,PB中同时连接多个数据库,如连接SQLServer2000和Oracle8 ,代码如下:

string ls_startupfile

ls_startupfile='hisini.ini'

sqlca.DBMS = ProfileString(ls_startupfile, "database", "dbms", "")

sqlca.database = ProfileString(ls_startupfile, "database", "database", "")

sqlca.userid = ProfileString(ls_startupfile, "database", "userid", "")

sqlca.dbpass = ProfileString(ls_startupfile, "database", "dbpass", "")

sqlca.logid = ProfileString(ls_startupfile, "database", "logid", "")

sqlca.logpass = ProfileString(ls_startupfile, "database", "LogPassWord", "")

sqlca.servername = ProfileString(ls_startupfile, "database", "servername", "")

sqlca.dbparm = ProfileString(ls_startupfile, "database", "dbparm", "")

remote_trans= CREATE transaction

remote_trans.DBMS = ProfileString(ls_startupfile, "Database_remote", "dbms", "")

remote_trans.database = ProfileString(ls_startupfile, "Database_remote", "database", "")

remote_trans.userid = ProfileString(ls_startupfile, "database_remote", "userid", "")

remote_trans.dbpass = ProfileString(ls_startupfile, "database_remote", "dbpass", "")

remote_trans.logid = ProfileString(ls_startupfile, "database_remote", "logid", "")

remote_trans.logpass = ProfileString(ls_startupfile, "database_remote", "LogPassWord", "")

remote_trans.servername = ProfileString(ls_startupfile, "database_remote", "servername", "")

remote_trans.dbparm = ProfileString(ls_startupfile, "database_remote", "dbparm", "")

//附hisini.ini

[Database]

DBMS=MSS Microsoft SQL Server 6.x

Database=his

UserId=

DatabasePassword=

ServerName=.

LogId=sa

Lock=

Prompt=0

computer='11'

ocx= 0

use0='之住院管理'

cfprint='1'

[Database_remote]

DBMS = "O84 Oracle8/8i(8.x.4+)"

ServerName = "oracle8"

LogId = "dba"

Database=zx

UserId=

DatabasePassword=

Lock=

Prompt=0

computer='11'

ocx= 0

cfprint='1'

给你copy一段吧:

PB连接多个数据库

2007-11-29 13:54:23| 分类: PB | 标签: |字号大中小 订阅

声明多个Transaction变量

Transaction SQLCA, SQLCB

SQLCA = Create

Transaction

SQLCB = Create

Transaction

然后做相应配置

SQLCA.DBMS = "ODBC"

SQLCA.AutoCommit = False

SQLCA.DBParm =

"ConnectString='DSN=********UID=***PWD=*******"

SQLCB.DBMS = "ODBC"

SQLCB.AutoCommit = False

SQLCB.DBParm = "ConnectString='DSN=*******UID=******PWD=*******'"

使用的时候直接用Connect Using SQLCA就可以连接上SQLCA所对应的数据库,使用Connect Using

SQLCB则可以连接上SQLCB所对应的数据库,可以在程序中保持同时和多个数据库的连接,而不需要在连接使用完后DISCONNECT,因为频繁的使用CONNECT与DISCONNECT可能会导致很多意想不到的问题发生。

要注意的是:当我们在程序中使用SELECT等SQL语句时,PB默认的是使用SQLCA进行数据库连接,所以当使用SELECT等SQL语句的时候,必须在末尾加上USING

******

比如:

Select Name

Into: Ls_Name

From

Students

Where Number = :Ls_Number

Using NewTransaction


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9941340.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存