Results 1 to 4 of 4

Thread: Changing Recordsets

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    69

    Angry Changing Recordsets

    I have a form which lets you type in criteria to search a table by.

    On that form I have textboxes that I bind to that recordset after they input their criteria and hit a search button.

    VB Code:
    1. Private Sub cmdSearch_Click()
    2.  
    3. If rsSearch.State = 1 Then rsSearch.Close
    4. rsSearch.Source = "SELECT * FROM MyTable WHERE MyField = '" & txtSearch.Text & "'"
    5. rsSearch.Open , connDB, adOpenStatus, adLockOptimistic
    6. Set textbox1.Datasource = rsSearch
    7.  
    8. End Sub

    Now, I have about 30 controls with the datafields already set that I set the datasource to that recordset. It works fine..

    My problem is, when they search a second time it goes REALLY slow. The only way I found to fix this was to set the controls datasource to Nothing before setting it to the RS.

    Seemed to work great until I watched the memory usage go UP UP UP every time you searched. It does not do that if dont set the controls datasource to Nothing first though.. What can I do?? HELP!

  2. #2
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    How's it declared?
    Dim rsSearch As New Recordset 'bad implicit declaration might lead to memory leak
    or
    Dim rsSearch as recordset
    set rsSearch = new recordset

    just guessing if a new instance of RS gets created with implicit declaration each time datasource references rsSearch.
    VB 6.0, Access, Sql server, Asp

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    69
    In the declarations I have:

    VB Code:
    1. Private WithEvents rsSearch As ADODB.Recordset

    and in the form load I have

    VB Code:
    1. Set rsSearch = New ADODB.Recordset

    The only time I do "Set rsSearch = New ADODB.Recordset" again is if the previous results returned 0 records. If I don't reset it the recordcount is always -1.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    69
    Am I the only one who experiences this problem? I just created another small app that uses Set MyControl.DataSource = Nothing and memory usage on the app goes up and up each time it does that.

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