|
本帖最后由 yidao8808 于 2011-8-22 09:59 编辑
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总是提示“对象打开时,不允许操作。” |
|