qtp查詢mysql QTP如何連線 查詢資料庫

2021-10-18 03:16:39 字數 1205 閱讀 4938

完整的連線指令碼**:

dim conn

set conn=createobject("adodb.connection")                             '建立資料庫例項

'const connectionstring="driver=;database=test;pwd=root;port=3306;server=localhost;uid=root"              '配置資料庫通行證

const connectionstring="driver=;database=datebase_name;pwd=password;port=3306;server=192.178.***。** ;uid=user_name"

conn.open connectionstring

if conn.state<>0then

reporter.reportevent micpass,"testing","連線資料庫成功"         '校驗資料庫是否成功連線

msgbox "連線資料庫成功"

else

reporter.reportevent micfail,"testing","連線資料庫失敗"

end if

set str=createobject("adodb.recordset")'建立資料集例項

'查詢資料庫

sql="select shop_id from taobao_shop"

str.open sql,conn,1,1'1,1表示唯讀;1,3表示插入資料;2,3表示修改資料

str.movefirst'使游標指向第乙個記錄

sum=""

while not str.eof

msgbox str.fields("shop_id")  '測試查詢得到的資料

for i=0to str.fields.count-1'str.fields.count表示字段個數

sum=sum & str(i) &""'把整個記錄顯示出來

next

print sum & vbcrlf'列印所有查詢的記錄

sum=""  '清零

str.movenext'使游標進入下乙個

wend

str.close '關閉資料集例項

set str=nothing

conn.close '關閉資料庫例項

set conn=nothing

qtp查詢mysql QTP中測試資料庫連線

祝大家新年快樂,有任何問題可與我聯絡 二 方式 1 set con createobject adodb.connection conset driver server oracle uid llr pwd llr con.open conset if con.state 0 then msgbox...

qtp查詢mysql QTP連線資料庫的乙個例項

定義乙個變數 dim cnn 建立乙個adodb物件,賦值給這個變數 set cnn createobject adodb.connection 連線指定的資料庫,使用者名稱密碼和資料來源名稱 data source就是步驟一建立的資料來源名稱 根據實際環境填寫 cnn.connectionstri...

請教qtp中如何操作treeview控制項

qtp中執行 window mywindow wintreeview mytreeview getitem 0 時,出了如下的錯誤 cannot identify the specified item of the tucroottree object.confirm that the specif...