Visit Gigasoft's Web Site
 ProEssentials v9 Help

Chapter 3: ActiveX and SQL Data

 

ProEssentials' ActiveX interfaces do not include embedded methods or features to automate reading SQL Data.

 

Instead, we provide example code and Classes showing how to read your SQL data.  The following example can be found in our Access example project. This example shows reading the data into a temporary array and then using PEvset to transfer the entire amount into ProEssentials with one call. This represents the fastest and simplest method of reading SQL data. The following code is also applicable within VB6.

 

The Access example project can be accessed via start menu...

Start / All Programs / ProEssentials v9 / Access Example Project

 

Public Sub LoadGraphDataFromQuery(PEGraph1 As Object, QueryName As String,_  PointLabelField As Integer)

    ' QueryName is the name of the query to base record set

    ' PointLabelField is normally (0) and identifies the field to load as PointLabels

    ' SubsetLabels will be based off the unique column names created via cross-tab

    

    Dim i, o, col, RecordCount, ColumnCount  As Long

    Dim TmpYData()  As Single

    Dim db ' As Database

    Dim rs ' As Recordset

 

    Set db = CurrentDb

    Set rs = db.OpenRecordset(QueryName)

   

    '** Determine size of data **'

    rs.MoveLast

    RecordCount = rs.RecordCount

    ColumnCount = rs.Fields.Count - 1

    

    '** Set Size of Graph Object to size of Tabled data **'

    PEGraph1.Subsets = ColumnCount

    PEGraph1.Points = RecordCount

    

    '** Fill TmpYData() with data and pass all at ounce **'

    ReDim TmpYData(ColumnCount * RecordCount) As Single

    rs.MoveFirst

    For col = 1 To ColumnCount

        i = 0

        Do Until rs.EOF

            o = ((col - 1) * RecordCount) + i

            TmpYData(o) = rs.Fields(col)

            rs.MoveNext

            i = i + 1

        Loop

        rs.MoveFirst

    Next col

    o = PEvset(PEGraph1.hObject, PEP_faYDATA, TmpYData(0), ColumnCount * RecordCount)

    

    '** Fill Column Labels as Subset Labels **'

    For col = 1 To ColumnCount

        PEGraph1.SubsetLabels(col - 1) = rs.Fields(col).Name

    Next

    

    '** Fill Point Labels **'

    i = 0

    rs.MoveFirst

    Do Until rs.EOF

        PEGraph1.PointLabels(i) = rs.Fields(PointLabelField) ' 0 field point labels

        i = i + 1

        rs.MoveNext

    Loop

End Sub