Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Switching from Local to Server Database
Sun, Feb 26 2012 7:02 PMPermanent Link

Colin Wood

VirtualTec P/L

Does anyone have an example of some code that allows a user to switch between a local database and a server version?  I’m sure it’s not all that complicated but I’d appreciate a push in the right direction.  So far I’ve got a single user local version running happily using an ini file to locate the config files.  What do I need to do to be able to check that the database exists and then to connect to it via the server ?  My previous DBISAM work only required local databases, but with Web Builder on its way I need to venture further afield.
Thanks
Colin
Sun, Feb 26 2012 11:12 PMPermanent Link

Colin Wood

VirtualTec P/L

… just noticed that my question is a bit unclear.  When I say “switch between a local database and a server version” I don’t mean that are two databases.  The database could either be local or remote, and there could be one or more copies of my app used to access the database.
Mon, Feb 27 2012 5:42 AMPermanent Link

AdamBrett

Fullwell Mill

Avatar

Colin:

The answer to your question depends slightly on how you have set up your EDB project in Delphi, but is incredibly simple.

Your EDBSession component has a few properties:

SessionType = (stLocal, stRemote);
RemoteAddress : string; //blank for local, 127.0.0.1 for EDBSRVR on local machine
LoginPassword : string; //same for local or remote
LoginUser : string; //same for local or remote

So long as you disconnect the Database and Session:

MySession.Connected:= false;
MyDatabase.Connected:= false;

You can then change these properties, reconnect and ... bingo ...

Note that EDBSRVR must be running on the local machine, and must have a config folder set in order to work.

--

Things get slightly more complicated if your application uses an EDBEngine component ... but not much.

Try a toy / sample app with Database - Session - Query components & you should have no problems.
Mon, Feb 27 2012 4:22 PMPermanent Link

Colin Wood

VirtualTec P/L

Hi Adam, I'm giving it a go today - I thought that there may have been a bit more to it that that... It will be good to have a few things go smoothly for a change SmileThanks for your response.
Regards
Col
Image