ConnectionString in app.config

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
degas
Posts: 77
Joined: Mon 16 Feb 2009 18:36
Location: Argentina

ConnectionString in app.config

Post by degas » Fri 11 Dec 2009 15:14

I have a small problem that is not crucial but is a bit annoying. I have been using your components for a WinForms application.
I am usign the InterFormLink component (wich is great by the way!!) and only 1 OracleConnection component for all my solution. The connection string is define in the app.config.
When the program excecutes, it shows a login form and ask the user for credentials. Those credentials should open the ConnectionString mentioned above. In other words, my users are OracleSchemas. This way i have security integrated with Oracle.

The problem is that the OracleConnection harcoded in the Designer.cs code so i cannot changed.
Is there a way to overcome this problem?

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 14 Dec 2009 12:32

You can set a reference to the connection put on another form either at design-time or at run-time. At design-time you can refer to the connection by some other component (like OracleDataTable) and then edit OracleDataTable.Connection. At run-time you can get the connection directly like this:

Code: Select all

OracleConnection con = (OracleConnection)Devart.Common.GlobalComponentsCache.GetObjectByName ("YourDataForm.YourConnection");
Please let us know if this helped.

degas
Posts: 77
Joined: Mon 16 Feb 2009 18:36
Location: Argentina

Post by degas » Mon 14 Dec 2009 13:04

Your solution works fine, but the i have the problem of setting all the Connections again for every DataTable i have.
This may cause error, because if i don`t set the OracleConnection, everything will run ok, because it is still taking the connection of the designer.
But on a production enviorment will not work.

What i wanted to do, was to be able to change the Connection that the designer is using at runtime.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 15 Dec 2009 09:03

Could you please send us a small project with the problem?

As far as I could understand, you are using the only OracleConnection for multiple DataTables and this connection is somehow set at design-time. Since OracleConnection is a reference type, its properties can be changed once in any DataTable.Connection and this will affect all other DataTables. Please let me know if I've missed something.

Post Reply