标题: 急!![ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.userss'. [打印本页] 作者: sissy0616 时间: 2009-3-30 16:13 标题: 急!![ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.userss'. (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