Using LIKE in DAO

This is a discussion on Using LIKE in DAO within the Windows Programming forums, part of the Platform Specific Boards category; I have tried using the like statement in DAO but it does not seem to work with the % Code: ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    Using LIKE in DAO

    I have tried using the like statement in DAO but it does not seem to work with the %


    Code:
    	strSql = _T("SELECT * FROM [TABLE01] WHERE [SME_PIN] = 'PIN01' AND [Event] LIKE 'EVENT01%'");
    
    rs.Open(AFX_DAO_USE_DEFAULT_TYPE, strSql );
    this seems to only open the recordsets that match the string exactly with the exception of the '%'. It will not pick up an event named 'EVENT01AA' for example. Is there a specific rule that must be followed for it to work.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    Maybe this will help...

    gg

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789

    Re: Using LIKE in DAO

    Originally posted by zMan
    I have tried using the like statement in DAO but it does not seem to work with the %


    Code:
    	strSql = _T("SELECT * FROM [TABLE01] WHERE [SME_PIN] = 'PIN01' AND [Event] LIKE 'EVENT01%'");
    
    rs.Open(AFX_DAO_USE_DEFAULT_TYPE, strSql );
    this seems to only open the recordsets that match the string exactly with the exception of the '%'. It will not pick up an event named 'EVENT01AA' for example. Is there a specific rule that must be followed for it to work.
    Try

    LIKE "EVENT01*"

    Works on Access

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    DAO using like

    I have tried the '*' and it does the same thing. I wonder why the LIKE does not work.
    zMan

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    Using Like works in DAO

    I know this is an old post but I think that it is worthwhile to respond.

    I just recently tried using the like statement in a query string and it worked. I don't know why it did not work before. (using dao through c++)

    Code:
    	s =  "SELECT * FROM [TABLE01] WHERE ";
    	s += "[Field01] LIKE '*FZJ*' ";
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DAO accessing Jet v4
    By Morgan in forum Windows Programming
    Replies: 3
    Last Post: 07-19-2004, 02:23 AM
  2. Mfc Dao Access Database
    By LISANANA in forum Windows Programming
    Replies: 1
    Last Post: 07-03-2003, 01:18 PM
  3. Combo Box / DAO / PropertyPage troubles
    By Robert602 in forum Windows Programming
    Replies: 7
    Last Post: 03-05-2002, 11:29 AM
  4. using DAO without MS Access installed
    By zMan in forum Windows Programming
    Replies: 2
    Last Post: 02-20-2002, 02:14 PM
  5. dao demo with embedded property sheet
    By zMan in forum Windows Programming
    Replies: 4
    Last Post: 02-09-2002, 05:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21