Question about Migrating from ODAC to UniDAC

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tadeus
Posts: 5
Joined: Tue 12 Jun 2012 07:06

Question about Migrating from ODAC to UniDAC

Post by Tadeus » Wed 15 May 2013 15:19

I am converting a project that used ODAC to using UniDAC.

This line doesn't compile:

OraConnection1.ConnectMode:=cmSysDBA;

OraConnection1 is a TUniConnection object.

What is the equivalent of this in UniDAC?

I have tried: OraConnection1.SpecificOptions.Values['ConnectMode']:=cmSysDBA;

But cmSysDBA is an unknown entity.

Am I close? Or completely out of the park?

Thanks for any help.

Tad

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Question about Migrating from ODAC to UniDAC

Post by AlexP » Thu 16 May 2013 07:47

Hello,

Parameter values in SpecificOptions are set as strings, i.e., you should set the parameters in the following way

Code: Select all

OraConnection1.SpecificOptions.Values['ConnectMode']:= 'cmSysDBA';

Tadeus
Posts: 5
Joined: Tue 12 Jun 2012 07:06

Re: Question about Migrating from ODAC to UniDAC

Post by Tadeus » Thu 16 May 2013 09:27

AlexP wrote:Hello,

Parameter values in SpecificOptions are set as strings, i.e., you should set the parameters in the following way

Code: Select all

OraConnection1.SpecificOptions.Values['ConnectMode']:= 'cmSysDBA';
Ok, it compiles, but I am getting an error: ORA-01031: insufficient privileges.

What is the proper way to connect to an oracle database as SYSDBA?

This is what I have now:

Code: Select all

    OraConnection1.Username:=<deleted>;
    OraConnection1.Password:=<deleted>;
    OraConnection1.SpecificOptions.Values['ConnectMode']:='cmSYSDBA';
    OraConnection1.Open;
When the Open method is called, the error message is displayed.

Tadeus
Posts: 5
Joined: Tue 12 Jun 2012 07:06

Re: Question about Migrating from ODAC to UniDAC

Post by Tadeus » Thu 16 May 2013 11:08

Tadeus wrote:
AlexP wrote:Hello,

Parameter values in SpecificOptions are set as strings, i.e., you should set the parameters in the following way

Code: Select all

OraConnection1.SpecificOptions.Values['ConnectMode']:= 'cmSysDBA';
Ok, it compiles, but I am getting an error: ORA-01031: insufficient privileges.

What is the proper way to connect to an oracle database as SYSDBA?

This is what I have now:

Code: Select all

    OraConnection1.Username:=<deleted>;
    OraConnection1.Password:=<deleted>;
    OraConnection1.SpecificOptions.Values['ConnectMode']:='cmSYSDBA';
    OraConnection1.Open;
When the Open method is called, the error message is displayed.
Ok...

I have figured out what was going wrong.

I set properties on the component for username, password, ConnectMode, etc. Then I clicked on Connected to establish a connection and it all worked. So, I removed all settings but username and password from my code and I was still getting the same error as before. I traced through the code and saw that the variables used for the username and password were no longer getting populated so they were getting set to '' which was causing my error. The reason they were no longer getting set is because they are stored in an MSSQL Database table and the function that gets those values from the table does a ping of the MSSQL server to make sure it is up before retrieving the data. I use the Indy ICMP client to do the ping and it was returning an error 10040 (Message too long). I tried reducing the packet size to 56, 32, 12 and finally 0, but kept getting the error. I noticed the Ping method had 2 optional parameters (ABuffer: String; SequenceID: Word), so I created an ABuffer and assigned it a value of Host+StringOfChar(' ',255) then called the Ping method with that parameter, it no longer got the 10040 error, the username and password values were properly retrieved and now the connection to the Oracle Server succeeds via my code.

All is well in the world, again.

Regards,

Tadeus

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Question about Migrating from ODAC to UniDAC

Post by AlexP » Mon 20 May 2013 06:25

Hello,

Glad to see that you solved the problem. If you have any other questions, feel free to contact us

Post Reply