[attach]74933[/attach]
Dim Cnn
Dim Rst
Dim strCnn
Set Cnn = CreateObject("ADODB.Connection")
Set Rst =CreateObject("ADODB.Recordset")
strCnn="provider=OraOLEDB.Oracle.1;Data Source=XXX;password=XXX;User ID=XXX; Security Info=True;"
Cnn.Open strCnn
If Cnn.State=0 Then
Reporter.ReportEvent micFail,"testing","数据库连接失败"
else
Reporter.ReportEvent micPass, "testing","数据库连接成功"
End If
msgbox Cnn.State
If Cnn.Open<>0 Then
strsql="select * from pets"
Rst.Open strsql,Cnn
ydl=Rst("name")
msgbox ydl
Set Rst=nothing
Cnn.Close
End If
运行到 If Cnn.Open<>0 Then总是提示“对象打开时,不允许操作。”作者: yidao8808 时间: 2011-8-22 10:01
求助求助。。大侠来帮忙啊作者: Ganve_001 时间: 2011-8-22 10:11
Cnn.Open<>0 还是Cnn.State<>0?作者: yidao8808 时间: 2011-8-22 10:21 回复 3#Ganve_001
真是粗心,是Cnn.State