Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 25th, 2007, 04:09 PM
Authorized User
Join Date: Dec 2003
Location: holtsville, ny, USA.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loading data from SQL

I am trying to find the fastest way to populate a combo box with data that's in a SQL Server DB.

I usually create a recordset and pass along a stored procedure as one of it's parameters to get the desired results(see below)

Set rc = New ADODB.Recordset

    If IsMissing(Company) = True Then
        SSQL = "EXEC [BuildActivityList] "
        If IsMissing(WeekOf) = True Then
            SSQL = "EXEC [BuildActivityList] '" & Company & "'"
            SSQL = "EXEC [BuildActivityList] '" & Company & "','" & WeekOf & "'"
        End If
   End If

   With rc
        .ActiveConnection = cnStandByPay
        .CursorLocation = adUseServer
        .Source = SSQL
    End With

    If rc.EOF = True Then
        BuildAccountDropDownList = ""
        Do While rc.EOF = False
            BuildAccountDropDownList = BuildAccountDropDownList & rc![Activity] & vbTab & Trim(rc![Description]) & "|"
    End If

    Set rc = Nothing

This works fine, but when the resulting recordset is big, it tends to slow down the displaying of the combo box.

I've also attempted to load all of the data as part of my start-up code(see code below), so I don't need to query the database, but using the .FIND method of a recordset is much slower than querying the database directly.

    SSQL = "exec [BuildActivityList]"

    With rsLawsonActivityCodes
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly
        .CursorLocation = adUseClient
        .Open SSQL, cnStandByPay
    End With

    rsLawsonActivityCodes.ActiveConnection = Nothing

I was wondering if there was a way to combine the two, so that I could create a secondary recordset based on the records I loaded at start-up, that would only have the records that I wanted to loop thru while populating the combo box.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Lots of Data bmains C# 2005 1 January 28th, 2008 12:57 PM
Loading Entity /w No Data pinch BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 20th, 2008 02:27 AM
Ch 3 - incremental data loading Johnslg BOOK: Expert SQL Server 2005 Integration Services ISBN: 978-0-470-13411-5 0 July 9th, 2007 01:08 PM
Loading data into List<T> rvincent C# 2005 8 June 14th, 2007 11:27 AM
Loading query data onto ASP page rweide Classic ASP Databases 9 October 13th, 2004 07:33 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.