Results 1 to 7 of 7

Thread: Adodc

  1. #1

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Adodc

    AdodcLine.RecordSource = "SELECT * FROM " & cboSite.Text
    AdodcLine.Recordset.Requery

    cboLine.Clear
    For intLine = 0 To AdodcLine.Recordset.RecordCount - 1
    'Add from Table Shift in Database
    cboLine.AddItem AdodcLine.Recordset.Fields(0)
    AdodcLine.Recordset.MoveNext
    Next intLine
    cboLine.Text = adoData.Recordset.Fields(0)

    however when i requery it doesnt pick the info from the new record source, can see is in the .recordsource

    goes through requery but Recordset.RecordCount is just the old info, like its not updated?

    please help
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Adodc

    If you are trying to get a count of the items in your combobox use Combo1.ListCount

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Adodc

    This will explain some issues with RecordCount
    http://www.vbforums.com/showthread.php?t=526882
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Adodc

    The Recordset does not "know" that the ADODC.RecordSource property was changed. It has its own Source property that contains the SQL Statement.

    When you change the ADODC.RecordSource call the ADODC.Refresh method which forces the ADODC to update/create its underlying Recordset.

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Adodc

    Instead of using Recordcount you can just use the EOF property to retrieve all the records.

    Code:
    Do While Not AdodcLine.Recordset.EOF
        cboLine.AddItem AdodcLine.Recordset.Fields(0)
        AdodcLine.Recordset.MoveNext
    Loop
    And it is always adviced not to use a data-bound control since they tend to present problems, you can just use plain ADODB, there is a tutorial on my sig on how to do that.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Re: Adodc

    Quote Originally Posted by brucevde
    The Recordset does not "know" that the ADODC.RecordSource property was changed. It has its own Source property that contains the SQL Statement.

    When you change the ADODC.RecordSource call the ADODC.Refresh method which forces the ADODC to update/create its underlying Recordset.

    AdodcLine.RecordSource = "SELECT * FROM " & cboSite.Text
    AdodcLine.Recordset.Requery

    am doing this but doesnt seem to work???

    what am i missing??
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Adodc

    Refresh not Requery

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width