Solved

Searching in CRecordset

Posted on 1998-10-02
4
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

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

Expert Comment

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

Accepted Solution

by:
MelissaC earned 100 total points
ID: 1322864
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
ID: 1322865
Thanks, all of the above work perfectly.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 76
windows 10 how make picture as desktop background 2 72
FizzBuzz challenge 9 87
unix example issues 18 113
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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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