pb连接数据库代码

pb连接数据库两种方式:
第一种 直接连接:

SQLCA.DBMS = "MSS Microsoft SQL Server"
SQLCA.Database = "TOPSKY0722"
SQLCA.LogPass = "futian"
SQLCA.ServerName = "."
SQLCA.LogId = "futian_user"
SQLCA.AutoCommit = False
SQLCA.DBParm = ""

disconnect using sqlca;
CONNECT USING sqlca;
if sqlca.sqlcode<>0 then
    messagebox('提示','连接数据库失败')
else
    messagebox('提示','连接数据库成功')
end if

第二种 通过配置文件来连接:
配置文件 YYGH_LINK.ini
内容:
[YYPT_LINK]
dbms=Mss microsoft SQL Sever 6.x
database=YYGHPT
userid=sa
dbpass=topsky
logid=sa
logpass=topsky
servername=127.0.0.1
DbParm=
firsttime=Yes
hospital_no=
LoginID=sa
LoginPass=topsky
Lock=
encrypt=N

连接代码:

Transaction trans_yypt
string ls_yyptmode,ls_startupfile_YY

ls_startupfile_YY = ".\YYGH_LINK.ini" //相对路径  同一文件目录下
ls_yyptmode = "YYPT_LINK" //配置文件中 节点([YYPT_LINK])

trans_yypt=create Transaction
        trans_yypt.dbms       = profilestring(ls_startupfile_YY,ls_yyptmode,"dbms",             " ")
        trans_yypt.database   = profilestring(ls_startupfile_YY,ls_yyptmode,"database",         " ")
        trans_yypt.logid      = profilestring(ls_startupfile_YY,ls_yyptmode,"logid",            " ")
        trans_yypt.logpass    = profilestring(ls_startupfile_YY,ls_yyptmode,"logpass",      " ")
        trans_yypt.servername = profilestring(ls_startupfile_YY,ls_yyptmode,"servername",       " ")
        trans_yypt.userid     = profilestring(ls_startupfile_YY,ls_yyptmode,"userid",           " ")
        trans_yypt.dbpass     = profilestring(ls_startupfile_YY,ls_yyptmode,"dbpass", " ")
        trans_yypt.lock       = profilestring(ls_startupfile_YY,ls_yyptmode,"Lock",             " ")
        trans_yypt.dbparm     = profilestring(ls_startupfile_YY,ls_yyptmode,"DbParm",           " ")
        CONNECT Using trans_yypt;
        if trans_yypt.sqlcode<>0 then
            messagebox('','预约平台库联结失败')
                return
        else
             messagebox('','预约平台库联结成功')
        end if
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页