ODBC problem

This is a discussion on ODBC problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I want to know what is wrong with this code: Code: CRecordset rSet(&DBConn); strQuery="SELECT * FROM People WHERE Names ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    ODBC problem

    Hi. I want to know what is wrong with this code:

    Code:
    	CRecordset rSet(&DBConn);
    	strQuery="SELECT * FROM People WHERE Names LIKE '*'";
    	rSet.Open(CRecordset::forwardOnly,(LPCSTR) strQuery);
    	if(!rSet.IsEOF())
    	{
    		rSet.MoveFirst();
    		while(!rSet.IsEOF())
    		{
    			rSet.GetFieldValue("Names",strData);
    			m_people_combo.AddString((LPCSTR) strData);
    			rSet.MoveNext();
    		}
    	}
    	rSet.Close();
    I know that this query should return results- it should return all the records in the table and I have some. But it doesn't return any records so the first condition is not true and it doesn't enter the loop. I tried to execute this query directly in MS Access and it works there. Any suggestions?

    How can I find out whether or not ODBC supports "LIKE" conditions?

    P.S. the DBConn connection is initialized properly- I know that because I use it in other places in the program.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,645
    I think you want to use '%' and not '*'
    I couldn't find any documentation on using '*' as a wildcard character for LIKE.

    gg

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    Thank you!

    It now works! I don't know why but in MS Access 2000 the query
    Code:
    SELECT * FROM People WHERE Names LIKE '*'
    works

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

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