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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle Casting problem??? Please help!!!

Status
Not open for further replies.

MindCracker

Programmer
Aug 27, 2002
21
0
0
GB
Hi Experts,

I need an URGENT help. I applied an ODBC through a Dialog Box (base class: CDialogODBC) to open a database. Then, I selected specified table available in the database before importing it into a new data structure which can be viewed as a set of matrix entries or information vectors.

In my CDialogODBC cpp file, all data from the selected table in the database are imported into the "table" which is my new data structure as defined (see below).

//////////////////////
///CDialogODBC.cpp////
/////////////////////
....
// Load table.
if!(importer->Apply(*table) {
Message::Error("Unable to open ");
return NULL; }
....

Now, I want this "table" to be available in my CProjectview so that I can use the data available in the "table". I applied this code:

CDialogODBC odbc(NULL);
// if user clicks OK button, update the database
if (odbc.DoModal() == IDOK) {

String str = odbc.tablestr;
//tablestr = table name in String;

ifstream stream;
stream.open(str.GetBuffer(), ios::in | ios::nocreate);

Handle<IS> table = dynamic_cast(IS *, const_cast(CDialogODBC::table));

if(!table->Load(stream)) {
Message::Error(&quot;Unable to open &quot;);
}

//where IS = information system, is my new data structure class

I got this error:

D:\Project\ProjectView.cpp(1712) : warning C4003: not enough actual parameters for macro 'const_cast'
D:\Project\ProjectView.cpp(1712) : error C2321: syntax error : unexpected 'CDialogODBC::table'
D:\Project\ProjectView.cpp(1712) : error C2143: syntax error : missing '(' before 'tag::id'
Error executing cl.exe.

I cant remember how to do this, the error could be the reason that I misuse the casting operator or perhaps I have missed something in the CDialogODBC. Can anyone please help me to fix this error????

Many thanks!!!!
Thank you!!
 
I think that you are not correctly applying dynamic_cast and const_cast. You should use:

dynamic_cast<IS *>(
const_cast<type_to_cast_to>(CDialogODBC::table)
);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top