2个回答
展开全部
1.SQL sp4
2.可以试着用ODBC测试看能不能连接上SQL,如果能连上,证明数据库没问题。
3.如果是脱离PB环境,检查你的DLL文件是否齐全。
4.如果不用SQLCA,代码如下:
If Not Fileexists("bzyb.ini") Then
MessageBox ("警告","找不到系统配置文件,请与管理员联系!")
Halt
End If
//定义事务对象
YBJK_YY = CREATE Transaction
YBJK_YY.DBMS = ProfileString("bzyb.ini","database","DBMS","")
YBJK_YY.Database = ProfileString("bzyb.ini","database","Database","")
YBJK_YY.LogPass = ProfileString("bzyb.ini","database","LogPass","")
YBJK_YY.ServerName = ProfileString("bzyb.ini","database","ServerName","")
YBJK_YY.LogId = ProfileString("bzyb.ini","database","LogId","")
YBJK_YY.DBParm = ProfileString("bzyb.ini","database","DBParm","")
CONNECT USING YBJK_YY ;
If YBJK_YY.Sqlcode < 0 Then
MessageBox ("警告","数据库连接失败,请检查配置文件")
Halt
End If
配置文件信息如下:
[database]
DBMS = MSS Microsoft SQL Server 6.x
Database = newhis
LogPass = 1234
ServerName = .
LogId = sa
AutoCommit = True
DBParm =
5.如果使用SQLCA,代码如下:
If Not Fileexists("his.ini") Then
MessageBox ("警告","找不到HIS系统配置文件,请与管理员联系!")
Halt
End If
//定义HIS事务对象
SQLCA.DBMS = ProfileString("his.ini","database","DBMS","")
SQLCA.Database = ProfileString("his.ini","database","Database","")
SQLCA.LogPass = ProfileString("his.ini","database","LogPass","")
SQLCA.ServerName = ProfileString("his.ini","database","ServerName","")
SQLCA.LogId = ProfileString("his.ini","database","LogId","")
SQLCA.DBParm = ProfileString("his.ini","database","DBParm","")
CONNECT USING SQLCA ;
If SQLCA.Sqlcode <> 0 Then
MessageBox ("警告","数据库连接失败,请检查配置文件")
End If
Open (w_pass)
配置文件如下:
[database]
DBMS = MSS Microsoft SQL Server 6.x
LogPass =
Database = bzmyy
ServerName = .
LogId = sa
AutoCommit = False
DBParm =
2.可以试着用ODBC测试看能不能连接上SQL,如果能连上,证明数据库没问题。
3.如果是脱离PB环境,检查你的DLL文件是否齐全。
4.如果不用SQLCA,代码如下:
If Not Fileexists("bzyb.ini") Then
MessageBox ("警告","找不到系统配置文件,请与管理员联系!")
Halt
End If
//定义事务对象
YBJK_YY = CREATE Transaction
YBJK_YY.DBMS = ProfileString("bzyb.ini","database","DBMS","")
YBJK_YY.Database = ProfileString("bzyb.ini","database","Database","")
YBJK_YY.LogPass = ProfileString("bzyb.ini","database","LogPass","")
YBJK_YY.ServerName = ProfileString("bzyb.ini","database","ServerName","")
YBJK_YY.LogId = ProfileString("bzyb.ini","database","LogId","")
YBJK_YY.DBParm = ProfileString("bzyb.ini","database","DBParm","")
CONNECT USING YBJK_YY ;
If YBJK_YY.Sqlcode < 0 Then
MessageBox ("警告","数据库连接失败,请检查配置文件")
Halt
End If
配置文件信息如下:
[database]
DBMS = MSS Microsoft SQL Server 6.x
Database = newhis
LogPass = 1234
ServerName = .
LogId = sa
AutoCommit = True
DBParm =
5.如果使用SQLCA,代码如下:
If Not Fileexists("his.ini") Then
MessageBox ("警告","找不到HIS系统配置文件,请与管理员联系!")
Halt
End If
//定义HIS事务对象
SQLCA.DBMS = ProfileString("his.ini","database","DBMS","")
SQLCA.Database = ProfileString("his.ini","database","Database","")
SQLCA.LogPass = ProfileString("his.ini","database","LogPass","")
SQLCA.ServerName = ProfileString("his.ini","database","ServerName","")
SQLCA.LogId = ProfileString("his.ini","database","LogId","")
SQLCA.DBParm = ProfileString("his.ini","database","DBParm","")
CONNECT USING SQLCA ;
If SQLCA.Sqlcode <> 0 Then
MessageBox ("警告","数据库连接失败,请检查配置文件")
End If
Open (w_pass)
配置文件如下:
[database]
DBMS = MSS Microsoft SQL Server 6.x
LogPass =
Database = bzmyy
ServerName = .
LogId = sa
AutoCommit = False
DBParm =
追问
我连数据库时,它提示我SQL sever 不存在吗,或者拒绝访问,怎么用ODBC测试呢
追答
设置--控制面板--ODBC数据源--默认打开是用户DSN--增加--在弹出的新建数据源左边选择最底下的SQL Server--单击完成--数据源名称任意--描述不用填--服务名如果是本地输入:. 或是127.0.0.1--下一步--如果你安装SQL的时候是混合验证方式那么直接下一步,如果是SQL验证方式就选择使用用户和密码的SQL验证,然后将用户名中的ADMINISTRATOR删除改为SA,密码就是SA的口令,再下一步--这里能够看到MASTER数据库一般就没有问题了,选择你要操作的数据库--下一步--完成。在完成窗口中可以测试一下数据源,如果测试成功,SQL应该没有问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询