Subject Re: modifying database path
From Mustansir Ghor <mustan31@hotmail.com>
Date Sun, 07 Nov 2021 13:26:11 -0500
Newsgroups dbase.getting-started

Dear Akshat

Thank you.

The below two statements is well understood. but I am finding difficult to understand  where to place them.

this.session = new session()
//new session
this.session.addalias("muneem","DBASE","Path:"+this.unc+this.direct)


I have mainform which has menu file associated with it. From there other forms get opened. In these forms I have database set  with path defined in the ini. I even use them while designing the forms. In the Below is the example PAYROL needs to have different path based on company selection. How this can be made possible

class payForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 27.3636
      left = -3.7143
      top = 0.3182
      width = 190.2857
      text = ""
   endwith

   this.DPAYROL = new DATABASE(this)
   with (this.DPAYROL)
      left = 86.0
      databaseName = "PAYROL"
      active = true
   endwith

   this.QPAY = new QUERY(this)
   with (this.QPAY)
      left = 97.0
      database = form.dpayrol
      sql = "SELECT * FROM MPAYROL"
      active = true
   endwith


Thank you and Best Regards
Mustansir

Akshat Kapoor Wrote:

> Good Evening Mustansir,
>
> >
> > I have a setup where an application runs for multiple companies. I have company.dbf that store company name and its database path folder.  But how can  than we  assign database name to the selected path for the company selected.
> >
> > Can Anybody help me on this
>
> Instead of using BDE alias use temporary database alias
> Sample code
>
> this.unc =  alltrim(company->unc)
> //Retrieve path from the table.
>
> this.session = new session()
> //new session
> this.session.addalias("muneem","DBASE","Path:"+this.unc+this.direct)
> //Create a database alias
> this.db = new database()
> this.db.session = this.session
> this.db.databasename = "muneem"
> this.db.active = true
>
> 'this' in the above code is a custom object mcompany.
>
> Then in dmd
>
> this.trans = new QUERY(this)
> with (this.trans)
> database = mcompany.db
>
> //use the alias declared above.
>
> sql = .................
>
> This is the code I am using.
> The database alias is temporary and can be reset any number of times.
>
> Regards
> Akshat