Console Application and DOA

Tierry

Member²
I am developing a console application using C++ Builder 6 and Direct Oracle Access 4.0.5.0. The code has been compiled without errors. However, when excuting the application I have got this exception runtime error message "Project PrintOcc.exe raised exception class EAccessViolation with message 'Access violation at address 004070D4. Read of address 74696F05'."
when trying to initialize the TOracleSession object:

Basically, I have initialize the TOracleSession like this:
---
TOracleSession * theSession;
if (!theSession->Connected)
{

theSession->LogonUsername = username;
theSession->LogonPassword = password;
theSession->LogonDatabase = servername;
theSession->Connected=true;
}
---
username, password and servername are AnsiString type.

This exception is raison as soon as I try to use
the TOracleSession object "theSession".

What am I doing wrong?

Thanks in advance for your help.
 
It is not a basd idesa to create an object before use it (this is applacable to any object, not to DOA objects only!).

TOracleSession * theSession;

doesn't create an object, theSession is only a pointer for object of TOracleSession type, and it is uninitialized. To initialize it you shall or assign to it an address of existing object or create new one by means of new operator, I have not programmed in C++ for many years so I'm not sure if following is syntacticelly correct, but you may check details in any C++ guide (or in ane demo program for DOA

theSession = new TOracleSession();

Originally posted by Tierry:
I am developing a console application using C++ Builder 6 and Direct Oracle Access 4.0.5.0. The code has been compiled without errors. However, when excuting the application I have got this exception runtime error message "Project PrintOcc.exe raised exception class EAccessViolation with message 'Access violation at address 004070D4. Read of address 74696F05'."
when trying to initialize the TOracleSession object:

Basically, I have initialize the TOracleSession like this:
---
TOracleSession * theSession;
if (!theSession->Connected)
{

theSession->LogonUsername = username;
theSession->LogonPassword = password;
theSession->LogonDatabase = servername;
theSession->Connected=true;
}
---
username, password and servername are AnsiString type.

This exception is raison as soon as I try to use
the TOracleSession object "theSession".

What am I doing wrong?

Thanks in advance for your help.
 
Initially, I have done it like you have mentioned that because it makes more sens to me. However, when I did that, I have got this compilation error message: " E2285 Could not find a match for 'TOracleSession::TOracleSession()'
".
It looks like there is no constructor for TOracleSession.

But, by removing, the code compiles but fails at run-time.

P.S.: The reference manual always to Delphi code. Although, most of the time, I could translate in C++, it would be great if I could find some demo in C++ for DOA but I don't know where I could fins some.
 
To complete my previous message about the compiling error message, here is the detailed explanation I have got from C++ Builder:
-----------------------------------
Compiler Errors: Delphi
Duplicate implements clause for interface ''

List of compiler error messages
The compiler has encountered two different property declarations which claim to implement the same interface. An interface may be implemented by only one property.

program Produce;
type
IMyInterface = interface
end;

TMyClass = class(TInterfacedObject, IMyInterface)
FMyInterface: IMyInterface;
property MyInterface: IMyInterface read FMyInterface implements IMyInterface;
property OtherInterface: IMyInterface read FMyInterface implements IMyInterface;
end;
end.
Both MyInterface and OtherInterface attempt to implement IMyInterface. Only one property may implement the chosen interface.

The only solution in this case is to remove one of the offending implements clauses.

-------------------

It is referring to a Delphi code.
 
Hi,

there is a constructor for TOracleSession:

pPrjOraSession = new TOracleSession(NULL);

As with all components it has one Parameter which is the owner.

Lars
 
Thanks a lot for this information. It works now. Is there any documentation where I could find this kind of information ?

By the way, I still have difficulty to get DOA Oracle Access working with a specific Oracle Home (Homex) directory when there is no entry in Oracle root. I have posted a message on this topic 3 weeks ago but I have still waiting for the answer. (See topic DOA vs multiple Oracle registry root)
 
Back
Top