Results 1 to 4 of 4

Thread: ADODB Recordset Filter problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    ADODB Recordset Filter problem

    dim rst as ADODB.Recordset
    set rst = new ADODB.Recordset
    rst.open select field1,field2 from table
    ..
    ..

    rst.Filter = "(field1 = 100)" it works!
    rst.Filter = "(field2 = 2 or field2 = 3)" it also works!

    but it doesnt work:
    rst.Filter = "(field1 = 100) and (field2 = 2 or field2 = 3)"
    //Error: wrong type or conflict between parameters..

    WHY?? plz help!!

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: ADODB Recordset Filter problem

    Luckily I ran into this once before.
    And fortunately I remember that I did find a way aorund it.
    And even more fortunately I was able to find it on MSDN
    The filter needs to be re-written.... it's a simple thing to do though:

    VB Code:
    1. rst.Filter = "(field1 = 100 and field2=2) or (field1 = 100 or field2 = 3)"

    Seems like a stupid thing to have to do, but it's the way ADO was written.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    Re: ADODB Recordset Filter problem

    I need a function which do this convertation for me automatically. I assembly the condition string in runtime...

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ADODB Recordset Filter problem

    It would probably be easier to change the way you build the string than write a function to convert it.

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