Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Enterprise
Expertise: Intermediate
May 12, 1998



Application Security Testing: An Integral Part of DevOps

Load a Grid From a SQL Statement

Here is useful code for a generic routine to load a grid from an SQL statement. The example shown is for RDO and Sheridan's grid, but works with minor modification for any grid and result set type. Also, you can load combo boxes in a similar fashion:
Public Sub LoadGridFromSQL(TargetGrid As SSDBGrid, rdoConn As rdoConnection, Sql As String, Optional ClearGrid As Boolean = True)
    Dim J As Integer
    Dim rsResult As rdoResultset
    Dim sAddItem As String
    If ClearGrid Then
    End If
    TargetGrid.Redraw = False
    Set rsResult = rdoConn.OpenResultset(Sql, rdOpenForwardOnly, rdConcurReadOnly, rdExecDirect)
    With rsResult
        Do Until .EOF
            'Build add item string
            sAddItem = vbNullString
            For J = 1 To .rdoColumns.Count
                If IsNull(.rdoColumns.Item(J - 1)) Then
                    sAddItem = sAddItem & vbNullString & vbTab
                    sAddItem = sAddItem & .rdoColumns.Item(J - 1) & vbTab
                End If
            Next J
            'Remove extra tab from end
            TargetGrid.AddItem Left$(sAddItem, Len(sAddItem) - 1)
    End With 'rsResult
    TargetGrid.Redraw = True
    Set rsResult = Nothing
End Sub
Joe Karbowski
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date