将"测试"进行到底!~!

How to connect to a database?--怎么连接上数据库?

上一篇 / 下一篇  2008-02-13 00:13:38 / 个人分类:QTP板块

How to connect to a database?
code:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set ōbjConnection = CreateObject("ADODB.Connection")
Set ōbjRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=<UID>;PWD=<PWD>"
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection
ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if

相关阅读:

TAG: QTP板块

 

评分:0

我来说两句

Open Toolbar