Intellipro      Your Ad Here

Automating QTP Test Automation                  Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map

Home

Automation

Articles

Downloads

QTP Gotchas

Links

Books

Contact

About

Site Map

 

 

 

 

 

SQL Function - Get Rows

This function retrieves rows from a database and loads then into an array.

For simplicity it requires a named odbc connection and only retrieves a single field.

Download it Here (right-click and then save target as).

(NOTE - you can just cut & paste from below, but the formatting will have multiple spaces instead of tabs).

'=========================================================================

Function zSql_GetRows(sDsn,sSql,sField)

'Usage:
'    Dim sDsn, sSql, sField, aRows, iRows, iRowIndex
'
'    sDsn = ""
'    sSql = ""
'    sField = ""
'
'    aRows = zSql_GetRows(sDsn,sSql,sField)
'
'    iRows = uBound(aRows)
'
'    If iRows = 0 Then
'        Msgbox "Nothing Found"
'    Else
'        For iRowIndex = 1 to iRows
'            sField = aRows(iRowIndex)
'            Msgbox sField
'            Wait 1
'        Next
'    End If

    Dim oCon, oRec, iCount, aRows()

    iCount = 0

    Set oCon=CreateObject("ADODB.Connection")
    Set oRec=CreateObject("ADODB.Recordset")

    oCon.Open("DSN=" & sDsn)

    oRec.Open sSQL,oCon

    If oRec.Eof Then
        'Nothing found
        ReDim aRows(0)

    Else
        'Read thru rows

        oRec.MoveFirst

        While Not oRec.EOF

            iCount = iCount + 1

            ReDim Preserve aRows(iCount)

            aRows(iCount) = oRec.Fields(sField)

            oRec.MoveNext

        Wend

    End If

    oRec.Close
    oCon.Close

    Set oRec=Nothing
    Set oCon=Nothing

    zSql_GetRows = aRows

End Function

'=========================================================================
Your Ad Here

Copyright © 2009 Intellipro Services Ltd. All rights reserved                      Home About Privacy Policy Terms of use Contact Site Map






































































advanced advice agile answers application articles aut automated automating automation basics beginners browser button checkbox child childobjects click close code coding combo combobox consultant consultancy convention count createobject database delete descriptive download downloads dp edit editbox element enhancements error examples faq faqs file files filesystemobject fixes folder folders forum framework frameworks function functions generation generator getobject getroproperty gotchas group guide guru harness hewlett hp inputbox insert intellipro interview language library libraries link list listbox manifesto manual master name naming navigate object or packard page ping pro problem procedure procedures professional programming qtp query queries question questions quick quicktest radio refresh repository ross row rows samples script scripts scrum select server software specific sprint sql step stored strategy structure sub subroutine suite sync tables test testing text textbox title tool tools tsl tutorial update updates url vbscript web webedit webpage webradiogroup weblist whittaker wscript