User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 373,477 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,982 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:

delphi object casting

Join Date: Oct 2007
Posts: 34
Reputation: adrive is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
adrive adrive is offline Offline
Light Poster

delphi object casting

  #1  
Dec 12th, 2007
i'm not sure if i'm getting this right, but i still remember java allowing me to cast an object to another type as long as their ancestors are the same?

I can't seem to do this in delphi, the compiler doesn't seem to understand the methods and attributes of each object even after I've casted them. What's wrong?

I'm trying to figure out how to stick two database query objects under the same name as illustrated :

qry : TObject;


if(callType = 'A') then
begin

//casting qry as a TOraQuery object :

qry := TOraQuery.Create(nil);
qry := commonObj.GetConnection('DATABASE_A');

qry.SQL.Add('DELETE FROM TEST1');
qry.ExecSQL;
qry.SQL.Clear;
end;

if(callType = 'B') then
begin

//casting qry as a TADOConnection object :

qry := TADOConnection.Create(nil);
qry := commonObj.GetConnection('DATABASE_B');

qry.SQL.Add('DELETE FROM TEST2');
qry.ExecSQL;
qry.SQL.Clear;
end;
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 5:29 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC