Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mapping database user to database
#4
Not Solved
Hi,

See below code, it works fine.

Code:
'    Connect to the flight 32 database
    Set Conn = CreateObject("ADODB.Connection")
    Set Rs = CreateObject("ADODB.recordset")
    'Conn.Open("DSN=Flight32")
    Conn.Open("DSN=QT_Flight32")
    
    'Specify the query
    
    sql = "Select * from Orders"
    
    'Set the recordset cursor type
    Rs.CursorType = 1 'set to a Keyset cursor type
    
    'Execute the Query
    Rs.Open sql,Conn
    
    'Get the no records returned by query
    Recordcount = Rs.RecordCount
    
    'Adding a column to datatable
    DataTable.GlobalSheet.AddParameter "Customer_Name",""
    
    'Get the values from the customer_Name column
    
    While(NOT Rs.EOF)
    
    'Msgbox Rs.Fields("Customer_Name")
    For i=1 to Recordcount
    DataTable.SetCurrentRow(i)
    
    'Writing the data to the datatable
    DataTable("Customer_Name",DtGlobalSheet) = Rs.Fields("Customer_Name")
    
    Rs.MoveNext
    Next
    
    wend
    
    'Exporting the Datatable to C:\DatabaseExample.xls
    DataTable.Export "C:\DatabaseExample.xls"
    
    'close the database connection
    
    Conn.close
    
    Set Conn = Nothing
    Set Rs = Nothing
Reply


Messages In This Thread
mapping database user to database - by kamalteja - 10-29-2010, 02:29 PM
RE: mapping database user to database - by KVK - 10-29-2010, 02:42 PM
RE: mapping database user to database - by MVChowdary - 11-01-2010, 05:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  MDB database Fresher88 0 2,111 09-04-2012, 11:26 PM
Last Post: Fresher88
  SQL on oracle database doesn't return a value Bluefields 2 3,233 07-09-2012, 01:23 PM
Last Post: Bluefields
  Remote database conenction ajayr1982 1 2,632 05-21-2012, 12:14 AM
Last Post: ravi.gajul
  Array as User-Defined Environment Variables Arena 3 4,259 04-16-2012, 09:19 AM
Last Post: sshukla12
  Importing Data from a Database rajeshwar 8 19,436 04-03-2012, 12:23 AM
Last Post: qtp-qa

Forum Jump:


Users browsing this thread: 3 Guest(s)