Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public or Protected variable of _RecordsetPtr doesn't work.

Status
Not open for further replies.

TheMillionDollarMan

Programmer
Jun 10, 2002
132
US
Hi,

I would like to create a class that handles my ADO database tasks. Here is my idea.

1. Delcare as public _RecordsetPtr then access all of its filds etc from another class.

2.
A.Declare a variable to _RecordsetPtr as private and have class memeber functions perform all of the database tasks. like _RecordsetPtr->MoveNext()
B. Map the fields of the Recordset to a public array so that a child class can access the data.

Problem:
When I put this into the header file ..
Public:
_RecordsetPtr spRSGlobal;
or even
Protected:
_RecordsetPtr spRSGlobal;

or even at the top of the implementation file..
_RecordsetPtr spRSGlobal;

The program compiles but then throws an exception when the program is starting up.
1. I have a global instance on the connection pointer and this doesn't create a problem.

Why can't I declare a global or even private variable of _RecordsetPtr type?

Thanks
Dave

VC++ 6.0
Windows 2000
MDAC version 2.1
Oracle 8.1.6


 
Sounds more like you are doing something with the pointer on startup without initializing it.

Verify that you dont still assume it is global.

Matt
 
Matt.
How do I
"Verify that I dont assume it is global?"

When it is declared a pointer from this within a function it is ok. As soon as I comment out the local declaration and make it private or public it belows up.

How could I use the pointer anywhere else if it wasn't Private/Public?


 
Which class are you putting it into?

When you create an object of that class in your program, wrap that part in a try...catch(_com_error &e) block. You can get a better description of what's going wrong from the e.Description() function.
 

I have wrapped the _RecordsetPtr variable in catch(_com_error ... when the _RecordsetPtr Variable is opened. My main problem is trying to create a public/private _RecordsetPtr Variable so that I can control the naviagtion through the recordset via a child class.

Basically I want a class that controls an ADO recordset. That class has to be able to navigate forward and backwards etc..

How do I do this?

Thanks
 
How to check for null values from record set??????
 
u probably are not creating an instance of the record set pointer , simply declaring the variable does not do the trick.
Use create instance before you use the pointer , and this should obviously be done in the class constructor , hope this help
Prasad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top