|
(QTP与SQL连接并读取SQL里的字段)
'定义变量
Dim con
dim conset
Dim rs
Dim sql
Dim names
Dim i
Set con=createobject("adodb.connection")
conset="DSN=xx;Description=qiau;APP=QuickTest Professional;WSID=xx;DATABASE=xx;Trusted_Connection=Yes"
con.open conset
If con.state=0 Then
msgbox"failed"
else
msgbox"pass"
End If
Set rs=createobject("adodb.recordset")
sql="select names from xx"
rs.open sql,con,1,3
rs.MoveFirst
Do until rs.eof
datatable.SetCurrentRow("i+1")
datatable.value("names",global)=rs("names")
msgbox rs("names")
rs.MoveNext
i=i+1
Loop
con.close
Set con=nothing
为什么RUN后报错,内容是:[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.userss'.
Line (31): "rs.open sql,con,1,3".
是不是因为没装ODBC的驱动? |
|