Subject Re: allowing user to change or add an alias
From Charlie <>
Date Mon, 19 Jun 2017 06:32:56 -0400
Newsgroups dbase.getting-started

Hi Akshat,

Thanks very much for the information.  I have tried this and understand it much better now.

I think that I may have a big problem although am not sure.

The vast majority of my forms are oodml.  However the vast majority of my programs are xdml.

Unless I misunderstand, I don't see a way of getting this to work with my xdml programs.  Am I correct?

Thanks again!!

Akshat Kapoor Wrote:

> Hello Charlie,
> On 18/06/2017 00:15, Charlie wrote:
>  > Hi Akshat..
>  >
>  > Thanks, I have looked at yours but don't get exactly what you are
> doing.  Could you send the tables?  Or the structure?  Possibly that
> would help me understand it.  If I can fix the permissions or whatever
> is causing the problem will work well.  But I still love
> learning other ways of doing things.  And that's a good thing because I
> have a whole lot to learn!!! :)
>  >
> There are two approaches to using variable databases I have tested. I
> will explain both
> Approach 1
> Create a temporary BDE Alias
> This is can be created/altered as and when you want. There is only one
> drawback It is not permanent in nature. It will be gone as soon as the
> session ends.
> mysession = new session()
> mysession.addalias("muneem","DBASE","Path:c:\dbasetutorial\muneem\1")
> /*The above two lines will create a new alias named "muneem" accessing
> "DBASE" tables in the path mentioned above.*/
> d = new database()
> d.session = mysession
> d.databasename = "muneem"
> = true
> /*
> Now I am using the session and database alias created above as a
> database I have an instance of the Database.
> */
> q = new query()
> q.database = d
> /*
> now I am using the database to access tables.
> */
> q.sql = "select * from vatrate"
> //I have not specified any path here. It will access the database for
> the table
> = true
> ?q.rowset.fields["tax"].value
> ?q.rowset.fields["tax"].value
> //The above 3 lines are just for testing from command line. You can omit
> these in your program and proceed
> You can declare a session in the first program (say first.prg)and it
> will be accessible to all programs/forms/reports that are called by
> first or down the tree structure.
> so if second.wfm is called by first and third.rep by second.wfm then the
> session/database will be accessible in third.rep also
> There is no limit to the depth of the tree structure. But if you declare
> the session in second.wfm it cannot be accessed by first.prg because the
> session ceases to exist as soon as execution of second.wfm ends. This is
> in accordance with normal scope of variable rules and how can they be
> accessed.
> There is a default _app session also But since I had not experimented
> with that session I have not mentioned it here
> You can go through the online help of addalias and class session.
> Approach 2
> In the first program declare a memory variable and store to full path in
> the memory variable.
>    mdirect = "C:\dbasetutorial\muneem\1"
> And then use this memory variable as part of sql string. You can use
> full path in any sql string and string functions like + can be used to
> generate the complete sql string.
> sql = 'select * from "' +mdirect+'\vatrate.dbf"' will be the same as typing
> sql = 'select * from "C:\dbasetutorial\muneem\1\vatrate.dbf"'
> The only difference is that the second option does not give you the
> option of variable directory.
> This approach suffers from a drawback. If you use calculated string in a
> form every time you open the form in designer the query
> sql = 'select * from "' +mdirect+'\vatrate.dbf"'
> is replaced by
> sql = 'select * from "C:\dbasetutorial\muneem\1\vatrate.dbf"'
> To avoid this situation you will have to use the Form_onOpen event to
> redeclare the query and requery. Or develop a datamodule with the query
> sql = 'select * from "' +mdirect+'\vatrate.dbf"'
> and use that data module in your form.
> If more details are required then please email with which approach you
> require the details.
> Regards
> Akshat