Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
oracle 10g db connection
#1
Solved: 11 Years, 4 Months ago Sad 
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
Reply
#2
Solved: 11 Years, 4 Months ago
Hi Tirumal,

Try:
Code:
While Not rs.EOF
Reply
#3
Solved: 11 Years, 4 Months ago
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
Reply
#4
Solved: 11 Years, 4 Months ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [UFT] Connection String for Oracle robertosalemi 6 12,301 01-15-2016, 04:51 PM
Last Post: robertosalemi
  DB2 Connect connection with IE 11 SRP 1 2,623 12-18-2015, 12:41 PM
Last Post: vinod123
  IBM DB2 connection with VB script bmurali 2 10,922 12-18-2015, 12:38 PM
Last Post: vinod123
  Connection with HP ALM hachem 0 2,629 02-26-2015, 04:36 PM
Last Post: hachem
  “Cannot connect to 8822 (connection timed out)" Ikbal 0 2,143 12-08-2014, 11:38 PM
Last Post: Ikbal

Forum Jump:


Users browsing this thread: 1 Guest(s)