Micro Focus QTP (UFT) Forums
oracle 10g db connection - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: oracle 10g db connection (/Thread-oracle-10g-db-connection)



oracle 10g db connection - tirumal - 02-16-2011

hi
below coding is executing but no result.
I m using qtp10.00 version and oracle 10g enterprise version

Code:
On error resume next
Dim cn,rs
Set cn= createobject("ADODB.Connection")
Set rs= createobject("ADODB.Recordset")
cn.Open "provider= ORAOLEDB ; server= orcl ; database=ORCL ; userid = scott ; password = tiger"
rs.Open "select * from emp " , cn

While rs.EOF <> True
print rs("empname")
rs.MoveNext
Wend
rs.Close
cn.Close



RE: oracle 10g db connection - manishbhalshankar - 02-16-2011

Hi Tirumal,

Try:
Code:
While Not rs.EOF



RE: oracle 10g db connection - Rekhapramod - 02-16-2011

Hi,

Use this below code to get the records and save it in excel file

Code:
var_Schema="QADB"
SchemaUserNme="GHA09"
SchemaPswd="GHA09"

Set conn=CreateObject("ADODB.Connection")
Set Rec=CreateObject("ADODB.Recordset")
Set obj=CreateObject("Excel.Application")
Set wrk=obj.Workbooks.Open("C:\Book1.xls")


conn.open "Driver={Microsoft ODBC for Oracle};Server="&var_Schema&";UID="&SchemaUserNme&";Password="&SchemaPswd&";"
SQL="Select * from  user_mas where role_id='FC'"
Rec.Open SQL,conn
R=1

Do until Rec.EOF
var1=Rec.Fields ("User_id")
Rec.MoveNext    
obj.Sheets(1).Cells(R,1).value=var1
'obj.Sheets(1).Cells(rowcount, 1).Value = var_user_id
R=R+1
Loop

Rec.Close
Set Rec=Nothing
conn.Close
Set conn=Nothing

obj.Application.activeworkbook.Save
obj.Application.activeworkbook.Close
obj.Application.Quit
Set wrk=Nothing
Set obj=Nothing



RE: oracle 10g db connection - surya_7mar - 02-17-2011

Try this...


Code:
Dim sDataSource
    sDataSource = envDBInstance
  
    Dim strConnection, oDbConn, rs, strSQL
    
    strConnection = "Provider=OraOLEDB.Oracle;Data Source=Oracle;User Id=SCOTT;Password=TIGER;"

    On Error Resume Next

    Set oDbConn = CreateObject("ADODB.Connection")
    oDbConn.Open strConnection
    
   Set oResultSet = CreateObject("ADODB.recordset")
    oResultSet.open sQuery, oDbConn, 3,3
    
    oResultSet.MoveFirst
    Dim arrOutput()
    Dim iIter, sDBRow,i
    iIter = 0
    Do Until oResultSet.EOF
            
        For i = 0 to oResultSet.Fields.Count - 1
            print(oResultSet.Fields(i) )
            
        Next
        oResultSet.MoveNext
    Loop
    oResultSet.close
    Set oResultSet = Nothing
    
    oDbConn.Close
    Set oDbConn = Nothing
    GetDBQueryData_Fun = arrOutput