|
qtp连接数据库
Const strconn = "rovider=SQLOLEDB.1ersist Security Info=False;User ID=saassword=sasa;Data Source=SINOOFFI-WINAPP"
Set conn=createobject("Adodb.Connection")
conn.Open strconn
If conn.State=1 Then
reporter.ReportEvent micPass,"数据库连接成功","stae=1"
else
' Exit do
End If
Set res=createobject("Adodb.recordset")
sq2005="select top 1 * from dbo.spt_monitor"
res.Open sq2005,conn
res.MoveFirst()
if res.Status = True Then
res = -1
reporter.ReportEvent micFail , "查询语句 "&sq2005& " 发生错误!"
Else
If res.EOF THEN
rel = 0
reporter.ReportEvent micFail , "查询语句 "&sq2005& " 发生错误!"
Else
i = 0
End If
' 将查询结果保存到动态datatable中
For each RstCol in Res.Fields
i = i+1
'datatable.AddSheet("SQL").AddParameter RstCol.name,""
datatable.GetSheet ("Global").AddParameter RstCol.name,""
n=0
While not res.EOF
n=n+1
For j = 0 to i-0
' datatable.SetCurrentRow n
datatable.Value( Res.Fields(j).name,"Global") = Res.Fields(j).value
Next
Res.MoveNext
Wend
rel =datatable.GetSheet("Global").GetRowCount
reporter.ReportEvent micPass ,"查询语句",""
Next
End If
你好,我想问,我在连接数据库时查询出来的数据怎么就有一个参数, |
|