(Newbie needs help: Pointer problem) 
Author Message
 (Newbie needs help: Pointer problem)

This is what I want to do. I have a dialog that allows the user to enter a
code and after the user enters the code and clicks on search button, the
program will return the location of the coded item in another field. The
database has already been opened by another CRecordset derived class created
by MFC. My idea of doing it will be to create a OnSearch function in the
SearchDialog class which should handle the searching of the code through the
database. That means I must have some how a method to access the variables
in the CRecordset derived class so that I can do a comparison between the
variables given to me in the search dialog class and the variables coupled
to the fields of the database. I thought that I should use a pointer to
point to this class to access functions like IsOpen, IsBOF and other
navigational functions like MoveNext(), etc. Here are a couple of questions.

a) Am I doing it the right way?
b) How do I get a pointer that points to the CRecordset derived class? In
other words, I need to know how I can get a pointer to an existing class
much like the GetDocument() function.
c) Is there an easier or faster way of doing it?

Thank you very much for answering my questions!

P/S: I am using ODBC and snapshot



Sat, 25 May 2002 03:00:00 GMT  
 (Newbie needs help: Pointer problem)

Quote:

> This is what I want to do. I have a dialog that allows the user to enter a
> code and after the user enters the code and clicks on search button, the
> program will return the location of the coded item in another field. The
> database has already been opened by another CRecordset derived class created
> by MFC. My idea of doing it will be to create a OnSearch function in the
> SearchDialog class which should handle the searching of the code through the
> database. That means I must have some how a method to access the variables
> in the CRecordset derived class so that I can do a comparison between the
> variables given to me in the search dialog class and the variables coupled
> to the fields of the database. I thought that I should use a pointer to
> point to this class to access functions like IsOpen, IsBOF and other
> navigational functions like MoveNext(), etc. Here are a couple of questions.

> a) Am I doing it the right way?
> b) How do I get a pointer that points to the CRecordset derived class? In
> other words, I need to know how I can get a pointer to an existing class
> much like the GetDocument() function.
> c) Is there an easier or faster way of doing it?

> Thank you very much for answering my questions!

> P/S: I am using ODBC and snapshot

You should pass the pRecordset to the dialog when you create the dialog.  One
way is to add a parameter to the dialog constructor:

  CMyDialog dlg(this, pRecordset);
  dlg.DoModal();

Save the pointer in a dialog member variable, then use it to access the
recordset.

There is a faster way of doing it if you code the search into
CRecordset::m_strFilter or pass your own SQL to CRecordset::Open.  Let the
database engine find the record instead of reading all the records yourself.

--
Scott McPhillips [VC++ MVP]



Sat, 25 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. newbie needs help with pointers

2. newbie needs help with pointers

3. help:pointer problem (newbie)

4. NEWBIE: Pointer List Problem -- Help?

5. Newbie needs help on simple problem

6. Need help with a pointer problem

7. Need help in function pointer problem in C++

8. Help C newbie need help please

9. Help C newbie need help please

10. HELP -- NEWBIE NEEDS HELP

11. newbie problem with pointers

12. Pointer to struct function NEWBIE PLEASE HELP

 

 
Powered by phpBB® Forum Software