Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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] "
    Else
        If IsMissing(WeekOf) = True Then
            SSQL = "EXEC [BuildActivityList] '" & Company & "'"
        Else
            SSQL = "EXEC [BuildActivityList] '" & Company & "','" & WeekOf & "'"
        End If
   End If

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

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

    rc.Close
    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.

Thanks!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.