Search code examples
delphialiasbde

Multiple users accessing the same BDE Alias, but accessing different directories


Background: I have an application written in Delphi that uses the Borland Database Engine (BDE) that looks at its data through a BDE Alias. I've managed to get it running via Remote Desktop Services, where each user looks at the same location for the data. Which is great if everyone wants to look at the same data. However I want to be able to get two groups (or more) of users looking at different data. I'm in the process of rewriting the application so that this situation is possible, but I need a stop-gap measure.

Question:

Is there a way for two applications to be looking at the same BDE Alias, but the directory that it refers to is different for each application?

or

Is it possible to have two users logged in via RDS (Remote Desktop Services - under Server 2008 or SBS 2008/11) to get two different configurations of the BDE? (one user sees the alias DATA to be c:\users\joe\data the other to see it as c:\users\bob\data for instance).


Solution

  • I've found two solutions to this, both use the TDatabase component. The first solution, if your alias name is MyAlias, you can create a TDatabase before you open any tables and set both the AliasName and DatabaseName to 'MyAlias', you can then open the TDatabase and set the Directory property to where you want to look for the data. This will override the Alias in the BDE with the local one, and any tables will be opened out of the directory you specify. This does not work if you are pulling stuff out of the default Session (Session.GetAliasParams for instance).

    The second solution is to setup another Alias in the BDE (MyOtherAlias for instance) and on your TDatabase component set the AliasName to 'MyOtherAlias' and the DatabaseName to 'MyAlias', again do this before you open any tables/queries. This seems to work much better and works with the default Session (if you pull out the directory for 'MyAlias', it will give the directory for 'MyOtherAlias').

    This is pretty esoteric, and I would be surprised if anyone else finds it useful - but then this is what makes stackoverflow great for answering obscure programming questions.