• RSS
  • Facebook
  • Twitter

One Center for all the Testing Need. OneTestingCenter is for all, for all QA, for all Automation. Automation is easy, fun and enriching experience. Happy Learning and Happy Testing!

  • Access to All QA

    At OneTestingCenter, you find lots of books,articles,blogs and detailed guides. Everyone has access to QA. Happy Learning, Happy Testing.

  • Global Trainings

    All the QA/Auotmation trainings are available at OneTestingCenter. QA, Automation, QTP/UFT, Selenium, LoadRunner, QC/ALM, Appium...

  • Automation Learning Fun

    Technology is always evolving. Automation is always challenging. To be frank, Automation is fun, enthusiastic and enrching experience.


    QT_Flight32 is the DSN created for QTP – Flight Application.
    Aim:
    To connect to the DSN= QT_Flight32
    Establish the connection using ADODB
    Check the DSN= QT_Flight32 connection
    Execute the query = Select * from Orders
    Get the number of columns and column names
    Get the number of rows
    Add a separate column for each column name in QTP-Flight DB
    Write rows data in the corresponding columns of the excel sheet

    ' Sample DataBase Test Script

    dim conn,rs
    Set conn=createobject("ADODB.Connection")
    Set rs=createobject("ADODB.recordset")
    strconnection="dsn=QT_Flight32"
    conn.open strconnection

    If conn.state=1 Then
                Reporter.ReportEvent micpass, "DB Connection sucesful" , "Passed"
                else
                Reporter.ReportEvent micpass, "DB Connection is not sucesful" , "Failed"
    End If

    Set rs=conn.execute("Select * from Orders")
    ' To Parameterize the script
    'Set rs=conn.execute(DataTable("SQL",dtGlobalSheet))

    Set flds=rs.fields
    DataTable.SetCurrentRow (0)
     For k= 0 to  flds.count-1
      rs= flds(k).name
      print rs
          datatable.GetSheet("Action1").Addparameter  rs,""
     Next

    ' Adding query values into excel
    set  rs = conn.Execute("  Select * from Orders")
    'Set rs=conn.execute(DataTable("SQL",dtGlobalSheet))
       rs.movefirst
     i=1
       While not  rs.eof
      DataTable.SetCurrentRow (i)
      For j=0 to flds.count-1
       DataTable( flds(j).name,"Action1")= rs.Fields( flds(j).name)
      next
      i=i+1
       rs.movenext
     Wend

    Results:






    Reactions:

    QTP - DataBase Testing (Demo1)


    QT_Flight32 is the DSN created for QTP – Flight Application.
    Aim:
    To connect to the DSN= QT_Flight32
    Establish the connection using ADODB
    Check the DSN= QT_Flight32 connection
    Execute the query = Select * from Orders
    Get the number of columns and column names
    Get the number of rows
    Add a separate column for each column name in QTP-Flight DB
    Write rows data in the corresponding columns of the excel sheet

    ' Sample DataBase Test Script

    dim conn,rs
    Set conn=createobject("ADODB.Connection")
    Set rs=createobject("ADODB.recordset")
    strconnection="dsn=QT_Flight32"
    conn.open strconnection

    If conn.state=1 Then
                Reporter.ReportEvent micpass, "DB Connection sucesful" , "Passed"
                else
                Reporter.ReportEvent micpass, "DB Connection is not sucesful" , "Failed"
    End If

    Set rs=conn.execute("Select * from Orders")
    ' To Parameterize the script
    'Set rs=conn.execute(DataTable("SQL",dtGlobalSheet))

    Set flds=rs.fields
    DataTable.SetCurrentRow (0)
     For k= 0 to  flds.count-1
      rs= flds(k).name
      print rs
          datatable.GetSheet("Action1").Addparameter  rs,""
     Next

    ' Adding query values into excel
    set  rs = conn.Execute("  Select * from Orders")
    'Set rs=conn.execute(DataTable("SQL",dtGlobalSheet))
       rs.movefirst
     i=1
       While not  rs.eof
      DataTable.SetCurrentRow (i)
      For j=0 to flds.count-1
       DataTable( flds(j).name,"Action1")= rs.Fields( flds(j).name)
      next
      i=i+1
       rs.movenext
     Wend

    Results: