以PB默认的数据库连接实例SQLCA为例
//连接参数设置SQLCA.DBMS = "MSS Microsoft SQL Server"
SQLCA.Database = "dbname" //数据库名称
SQLCA.LogPass = 逗地//用户密码
SQLCA.ServerName = "192.168.0.251"
SQLCA.LogId = "sa"//SQLserver用户名
SQLCA.AutoCommit = True
SQLCA.DBParm = ""
//连接
CONNECT USING SQLCA
首先,创建一个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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)