SetConnectionStringForSession

Please

I need to connect to the second database, I'm using "DatabaseConnection_SetConnectionStringForSession", I tried to do it this way, but it didn't bring me the result of the second database, keep showing me database number 1 am I doing something wrong?

connectionName = "Db1"

connectionString=  "Uid=Usuario;Pwd=Senha;Server=Servidor;Database=Base;"



Hello Marcelo,

Most likely, it is because they're in the same Web Request and the switch didn't happen by the time you execute the query.

If you check the documentation, there are some conditions to which you have to pay attention when using DatabaseConnection_SetConnectionStringForSession action.

Can you try to do that using 2 different Web Requests?


For example, you can have 2 different buttons:

  1. Button1 for the first Web Request that calls DatabaseConnection_SetConnectionStringForSession action
  2. Button2 for the second Web Request that executes the query


Please make sure you're logged in with a user and you have a valid Session.


Kind regards,

Rui Barradas

thanks for the quick return

I did as you instructed, but continue to bring data from database number 1

do you have any idea?





Hi again Marcelo,

Is your screen "Main" an anonymous screen? Do you have a valid Session for a User? I think that you need to do an OutSystems Login before calling that action because the switch occurs for the current Session.

Can you verify in Service Center if there is any errors associated to that action? It would be nice to verify if the defined connection is working properly.


Kind regards,

Rui Barradas

hi thanks for the return again

My screen is not anonymous, I ended up testing it anonymously but it remains the same.


Where can I check at the Service Center if my action is working correctly?

Hi Marcelo,

My question about the screen was just to validate if you have a valid session for a logged user or not.


In Service Center, you should go into Factory -> Extensions -> PlatformRuntime_API. Then go to the Operation tab and click into the check box to log calls to that extension.

After that, every single call to an action of that extension should be logged in Extension Logs (Monitoring -> Extensions).

Call that action again and check the resulting logs of it.


Kind regards,

Rui Barradas

no mistakes, Any idea ?