Solved

Searching in CRecordset

Posted on 1998-10-02
4
181 Views
Last Modified: 2013-11-20
I have a program that uses an Access database through ODBC. In order to search for a particular record I go record by record checking the search criteria. Is there an easy way of doing this, such as a WHERE clause.
0
Comment
Question by:santama
  • 2
4 Comments
 

Expert Comment

by:mmachie
Comment Utility
look at CRecordset::GetDefaultSQL() or you can specify an SQL statement in the Open function.
0
 

Expert Comment

by:mmachie
Comment Utility
forgot to mention Requery and the data members m_strFilter and m_strSort.
0
 
LVL 2

Accepted Solution

by:
MelissaC earned 100 total points
Comment Utility
When you've derived your own CRecordset class, you've allready got the member variables that are needed for your full query (the entire table). Instead of just saying CMyset.Open(), you can create an SQL-string:

CString sql="Select * from mytable where ID=123";
//then open your recordset with:

CMyset newset();  //create recordset
newset.Open(recordset::dynaset, sql);

//move to first record (if recordset!=empty)
newset.MoveFirst();

Now your recordsetcursor points at the record you need.
0
 

Author Comment

by:santama
Comment Utility
Thanks, all of the above work perfectly.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now