Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
How to find TDBISAMDatabase by databasename |
Wed, Mar 1 2006 5:11 PM | Permanent Link |
Danny Humphress | I need to specify the SessionName when opening a table (multi-threading with unique session names). The problem is that I have a lot of generalized
units that open tables using only a generic database name ("db1"). That database name refers to a TDBISAMDatabase component that has a session attached to it. How can I find what session it is? Here's what I have tried: with TDBISAMTable.Create(nil) do begin DatabaseName := 'db1'; SessionName := Database.SessionName; // <- Error here because Database is nil end; Is there an engine function or something that can give me the actual database reference based on the database name? thanks, Danny |
Wed, Mar 1 2006 9:20 PM | Permanent Link |
Jeff Cook | Danny Humphress <danny@humphress.com> wrote on Wed, 1 Mar 2006 17:11:33 -0500
>I need to specify the SessionName when opening a table (multi-threading with unique session names). The problem is that I have a lot of generalized >units that open tables using only a generic database name ("db1"). That database name refers to a TDBISAMDatabase component that has a session >attached to it. How can I find what session it is? > Danny You might be able to find the database like this:- for i := 0 to ComponentCount - 1 do begin if Components[i] is TDBISAMDatabase then begin SessionName := (Components[i] as TDBISAMDatabase).SessionName; break; end; end; HTH Cheers Jeff -- Jeff Cook Aspect Systems Ltd Phone: +64-9-424 5388 Skype: jeffcooknz www.aspect.co.nz |
Thu, Mar 2 2006 5:41 AM | Permanent Link |
Danny Humphress | Jeff,
Thanks. I ended up writing the following. It seems like a complicated way to get a reference to a database by its name. I thought there might be a simplier solution: function GetDatabaseByName( ADatabaseName: string ): TDBISAMDatabase; var i, j: integer; begin Result := nil; i := 0; while (i<Engine.SessionCount) and (Result=nil) do begin j := 0; while (j<Engine.Sessions[i].DatabaseCount) and (Result=nil) do begin if ANSICompareText(Engine.Sessions[i].Databases[j].DatabaseName,ADatabaseName)=0 then Result := Engine.Sessions[i].Databases[j]; inc(j); end; inc(i); end; end; |
Thu, Mar 2 2006 9:37 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Danny,
<< I need to specify the SessionName when opening a table (multi-threading with unique session names). The problem is that I have a lot of generalized units that open tables using only a generic database name ("db1"). That database name refers to a TDBISAMDatabase component that has a session attached to it. How can I find what session it is? >> Loop through the Engine.Sessions property and call this method for each session: http://www.elevatesoft.com/dbisam4d5_tdbisamsession_finddatabase.htm http://www.elevatesoft.com/dbisam4d5_tdbisamengine_sessions.htm http://www.elevatesoft.com/dbisam4d5_tdbisamengine_sessioncount.htm -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |