Hi.
Our solution suppose to allow users switch between data companies(multiple databases with same structure by company). I use databaseManager.switchServer command. It seems every thing works when I try to update,delete,insert data , but when I try to get server name on the form level ,using _server_name = databaseManager.getDataSourceServerName(controller.getDataSource()) it always return me the server name what I used during design.
If somebody can explain how the switchServer works. It seems it done internally on the savedata, but in this case a lot off commands in DatabaseManager as for example, databaseManager.getDataSourceServerName is usefulness.
Leonid,
When you switch from database server using databaseManager.switchServer(orig, new), the switch is transparent to all your code (with one exceptions).
So all your forms and your code still works with the orig server and Servoy maps this to actual queries to the new server.
controller.getDataSource() will also return the original server name.
One exception is the rawsql plugin, this plugin does not understand the mapping from databaseManager.switchServer() so there you have to use the new server name.
If you do not use the rawsql plugin you should not need to know in your code what the actual server is, otherwise you need to remember this in the code where you do the switchServer() call.
Rob
Another question:
I want to switch from server1 to server2, so I have to use:
DatabaseManager.switchServer(server1, server2)
Ok, but now I want to switch to server1 again. What’s the right code?
DatabaseManager.switchServer(server1, server1)
or
DatabaseManager.switchServer(server2, server1)
?
Hi,
Juan the server name suppose to switch before the forms loaded to solution. I just curious what happens if solution originally used 2-3 different databases.
Thanks Rob, for your explanation.
This is the right code:
juan.cristobo:
DatabaseManager.switchServer(server2, server1)
Ok, thanks, Rob.