TA的每日心情 | 奋斗 2018-8-27 15:56 |
---|
签到天数: 322 天 连续签到: 1 天 [LV.8]测试军长
|
使用ODBC链接
Function CreOraLink(provider,userid,passwd,dataip,strsql,columnname)
Dim Cnn,strCnn
strCnn ="rovider="&provider&"assword="&passwd&"ersist Security Info=True;User ID="&userid&";Data Source="&dataip
Set Cnn = CreateObject("adodb.Connection")
Cnn.Open strCnn
If Cnn.State = 0 Then
Call PopBox("创建数据库链接失败",30,"数据库链接")
End If
'Generate the recordset object
Set Rs = CreateObject("ADODB.Recordset")
'excute sql
Rs.Open strsql,Cnn,1,3
'if you want judge the database state,must define(DS_dbrc) a global variable in QTP
DS_dbrc = Rs.Recordcount
if DS_dbrc <> 0 Then
DS_dbvalue = Rs(columnname)
if DS_dbvalue <> "" Then
DS_dbvalue = Cstr(DS_dbvalue)
End if
else
DS_dbvalue = ""
End if
Rs.close
Set RS=nothing
Cnn.Close
Set Cnn=nothing
End Function |
评分
-
查看全部评分
|