298
Views
5
Comments
Change in runtime the external database connection
Question

I'm trying to connect to two different databases with the same structure using the DatabaseConnection_SetConnectionStringForSession function

after using this action, we were unable to connect to the other database, it is still fetching data from the default database.

Note:

   - In the Studio Integration the entities changed [db1]. [Dbo]. [Table], for [table].

   - ConnectionName: <DB2 Connection Name>

   - ConnectionString: "Server = SERVER; Database = DB2; User Id = sa; Password = P;"

2026-04-01 11-40-30
Mahesh Manchala

Hi,

I guess it is possible to create an extension and do it inside your extension by passing the details of the server and the data to be updated in run time.

Its just my suggestion..

2021-07-07 13-36-32
Hans Dollen

you can only change the connection in a session when, for that session, you haven't used the existing database connection.

KR Hans

UserImage.jpg
Marcelo Valle Palladino

I tried to do it that way, but it didn't bring me the result of the second database, am I doing something wrong?


2021-07-07 13-36-32
Hans Dollen

Can you show how you defined the entity/table mapping in integration studio? It might be that you defined the database and schema hardcoded. 


2020-02-14 13-26-37
Sai Ravali Perni

Hans Dollen wrote:

Can you show how you defined the entity/table mapping in integration studio? It might be that you defined the database and schema hardcoded. 


 Hi Hans,


Can you please specify if there is any format to define entity mapping integration studio? I am also trying to achieve the same as Marcelo but when I remove the database and schema mapping in integration studio, the sql query gives me invalid object error for that table.


Please help!


Thanks in advance

Sai Ravali

 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.