Sc_change_connection : try and error

Control A makes sc_change_connection and then a redir to another App B (Control or Form):
Sometimes it works properly, sometimes not and App B still refers to old connection. Tho code was not changed.
This is deadly for production, because after that the sql-Commands in App B go to the wrong database. Sometimes this error occurs, sometimes not. Don’t know why.

In addition : if App B ist a grid … everything is fine … Only Control and Form App will not work properly.

Anyone faced the same problem ?
On the linux production system this error never happens.
A windows server development problem ??

Best regards
Uwe

hi Uwe , i do not think it is a good practice to switch connections on the fly.
if you a user wants to change an environment he should logout and login again with different connection settings. you see this practice in almost all software. in the menu you can show the active connection and make sure the user can see in what environment he is working at all times. this is very important when working with multiple environments.
i used to change the connections on user login validate. never had problems.
I agree that changing connection on the fly can be handy in some scenarious but i could not manage it to work. it seems some caching or something blocks some changes. i had it on lynux ,
good luck

Thanks for your comment.
I don’t change it on the fly … but now I made it like you supposed. The login page is called with URL parameter ?db=xxx . In OnScriptInit Event I change once the connection. On development server it sometimes does not word (Windows), on LINUX production server no problem. I will see.

Thx
Uwe

I have new infos . Obviously it’s a problem of caching. Even if I change_connection → redir to another application … it will not work THE FIRST TIME !! . If I do it several times, suddenly the connection changes. Looks like a problem of caching (Windows Server 2022 on production). but how to avoid this behavior ?

Best regards
Uwe