PB6.5登录窗口读取配置文件,多个数据库,登陆时可选择数据库连接怎么做求大神帮忙看看

PB6.5登录窗口读取配置文件,多个数据库,登陆时可选择数据库连接怎么做求大神帮忙看看,第1张

1、ini配置文件大致格式

[db1]

server = 192.168.0.1

user = sa

passsword = 123

[db2]

server = 192.168.0.2

user = sa

passsword = 123

2、下拉菜单选项,比如是db1,db2

3、在下拉菜单的selectionchanged事件中,参考选中选项,读取ini参数,进行数据库连接即可,比如

string ls_sever,ls_user,ls_pw

ls_sever = ProfileString("PROFILE.INI", text, "server", "")

ls_user= ProfileString("PROFILE.INI", text, "user ", "")

ls_pw= ProfileString("PROFILE.INI", text, "passsword ", "")

//然后连接数据库即可

首先,创建一个connect.ini文件,其内容为: [Database]

DBMS=MSSQL SQL Server 2000

Database=erpUserId=saDatabasePassword=LogId=saLogPassword=

ServerName=familyDbParm=Lock=Prompt=0其中:erp指您要连接的数据库名称;SA是数据库连接ID,Family是指您要连接的数据库的计算机名称,也可以用IP地址来代替。接下来,我们就在系统应用的Open事件中进行编码: string ls_inifile ="connect.ini"

//进行数据库连接------------------------------------------------

sqlca.DBMS = ProfileString ("dbconnect.INI", "database", "dbms", "")

sqlca.database = ProfileString ("dbconnect.INI", "database", "database", "")

sqlca.logid = ProfileString ("dbconnect.INI", "database", "logid", "")

sqlca.logpass = ProfileString ("dbconnect.INI", "database", "LogPassWord","")

sqlca.servername=ProfileString("dbconnect.INI","database", "servername", "")

sqlca.dbparm = ProfileString ("dbconnect.INI", "database", "dbparm", "")

sqlca.autocommit=true

connect using sqlca

Messagebox("错误","不能连接到数据库!请检查数据库连接或者ini配置")elseend if

可以的,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'


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存