51Testing软件测试论坛
标题:
搞掂!
[打印本页]
作者:
netsky_lt
时间:
2006-4-29 15:26
标题:
搞掂!
Dim Cnn
Set Cnn = CreateObject("ADODB.Connection")
Cnn.ConnectionString = "Provider=MSDAORA.1;User ID=XXX;Password=XXX;Data Source=DBSERVER;Persist Security Info=True"
Cnn.Open
If Cnn.State = 0 Then
Reporter.ReportEvent micFail, "testing", "连接数据库失败"
else
Reporter.ReportEvent micPass, "testing", "连接数据库成功"
End If
作者:
pcl2004_27
时间:
2006-5-5 11:22
代码 修改如下
Dim Cnn ' as adodb.connection
dim strLink ' as string
strLink== "Provider=MSDAORA.1;User ID=XXX;Password=XXX;Data Source=DBSERVER;Persist Security Info=True" ' 这么写可以更加灵活,将来i数据库移植,只要修改字符串就可以了
Set Cnn = CreateObject("ADODB.Connection")
cnn.open strLink '打开连接
If Cnn.State = 0 Then
Reporter.ReportEvent micFail, "testing", "连接数据库失败"
else
Reporter.ReportEvent micPass, "testing", "连接数据库成功"
End If
‘注意这里,声明的对象需要释放掉,否则存在内存泄露问题
cnn.close
set cnn=nohting
作者:
suifengpiao
时间:
2007-1-25 14:00
xue xisdlkfj2
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2