Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 18 total |
More config path confusion |
Fri, Mar 13 2009 7:45 AM | Permanent Link |
Peter Thorne | Hi,
I don't think this is covered by the recent post. This is my deployable code for setting the config and temp tables path in 1.9. I am sure it is familiar to many! procedure TdmStraw.DataModuleCreate(Sender: TObject); begin ExeLocation := ExtractFilePath(Application.ExeName); engStraw.Active:=True; sesStraw.Connected:=True; with qryConfiguration do begin SQL.Text:='SELECT * FROM Databases WHERE Name=' + Engine.QuotedSQLStr('Straw'); Open; if (RecordCount = 0) then begin Close; SQL.Text:='CREATE DATABASE "Straw" PATH '+ Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'Data'); ExecSQL; end else Close end end; procedure TdmStraw.engStrawBeforeStart(Sender: TObject); begin with engStraw do begin ConfigPath := ExeLocation; TempTablesPath := GetTempTablesPath; end; with sesStraw do begin LoginUser := 'Administrator'; LoginPassword := 'EDBDefault'; end; dbStraw.Database := 'Straw' end; This creates a new config file in whichever directory the user deploys to . It seems to works about 95% of the time as long as engStraw.ConfigPath and engStraw.TempTables path are left blank and the engine is not active at compile time. After an upgrade to 2.02 (Build 10) it throws an error 409 (config path empty). If you fill in the config path, it works OK on the development machine but won't deploy to another machine (as it can't unsurprisingly find the development path). What settings do I need to modify to get it working again. Thanks Peter |
Fri, Mar 13 2009 8:52 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
>This creates a new config file in whichever directory the user deploys to . It seems to works about 95% of the time as long as >engStraw.ConfigPath and engStraw.TempTables path are left blank and the engine is not active at compile time. After an upgrade to 2.02 (Build >10) it throws an error 409 (config path empty). If you fill in the config path, it works OK on the development machine but won't deploy to another >machine (as it can't unsurprisingly find the development path). What settings do I need to modify to get it working again. I think I can understand it not working if the engine is active in the IDE, probably a matter of timing of events (eg it could be set to active before the events are hooked up), but it should be 100% not 95%. Others may disagree but unless you're going to be starting and stopping the engine in the app I'd put all of the start up code in TdmStraw.DataModuleCreate. Its not exactly masses of code and its a lot easier to follow if its all in one place and it will all flow smoothly in the right order. If you want to keep it as a separate function make it a function call from TdmStraw.DataModuleCreate rather than an event. Roy Lambert [Team Elevate] |
Fri, Mar 13 2009 9:27 AM | Permanent Link |
Peter Thorne | Roy Lambert wrote:
Peter I think I can understand it not working if the engine is active in the IDE, probably a matter of timing of events (eg it could be set to active before the events are hooked up), but it should be 100% not 95%. Others may disagree but unless you're going to be starting and stopping the engine in the app I'd put all of the start up code in TdmStraw.DataModuleCreate. Its not exactly masses of code and its a lot easier to follow if its all in one place and it will all flow smoothly in the right order. If you want to keep it as a separate function make it a function call from TdmStraw.DataModuleCreate rather than an event. Roy Lambert [Team Elevate] Roy, Thanks for the quick response and good thinking. If I take the code that assigns the paths out of the Engine.BeforeStart and stick it at the top of the DataModule.OnCreate it seems to do the trick. Maybe, the examples should be changed as this is where I pinched my original code from! I guess there is also a potential issue here if, as you say, someone wants to restart the engine during runtime. Cheers Peter PS I agree, it should be 100% |
Fri, Mar 13 2009 9:47 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
Ever since I started using Delphi (my first foray into Windows events) I've always felt that the non-deterministic manner in which events can fire is a significant problem. Maybe it is deterministic if you know what's going on under the hood, and if you ever meet the guy who knows I'd like an introduction. I'd also like a few quid for every time I'd had to chase an error down stepping though a few gazillion lines of code because events aren't firing in the order I expected. Roy Lambert |
Fri, Mar 13 2009 12:12 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Peter,
<< After an upgrade to 2.02 (Build 10) it throws an error 409 (config path empty). If you fill in the config path, it works OK on the development machine but won't deploy to another machine (as it can't unsurprisingly find the development path). What settings do I need to modify to get it working again. >> What line of code throws the "config path is empty" error ? Are you sure that you're not leaving the engine set to Active at design-time ? The empty configuration path check is actually done when a local session tries to connect, so the code that you show should work fine. In fact, it's basically the same code that we use with the CDCollector application. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Mar 16 2009 6:27 AM | Permanent Link |
Peter Thorne | What line of code throws the "config path is empty" error ?
Are you sure that you're not leaving the engine set to Active at design-time ? The empty configuration path check is actually done when a local session tries to connect, so the code that you show should work fine. In fact, it's basically the same code that we use with the CDCollector application. Tim, Interestingly (perhaps), it is the connection to the session that throws the error (sesStraw.Connected := true). The preceding "engStraw.Active:=True" doesn't cause a problem. If I set a breakpoint in the Engine.BeforeStart, this does not fire. Yes (1000 times) the engine is not active - I discovered this one in my early attempts to deploy (at about version 1.05 I think). One thing that may or may not be significant is that these tables were created in 1.09. I wasn't sure if they would be compatible with 2.02 but they do appear to be apart from this (soluble) problem. Peter |
Mon, Mar 16 2009 7:02 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
What I did to make sure of not having things set to active was to install GExperts and use it to set several properties to false - basically any of the TEDB... stuff. Roy Lambert |
Mon, Mar 16 2009 1:54 PM | Permanent Link |
Peter Thorne | >> Roy Lambert wrote:
>> >> What I did to make sure of not having things set to active was to install GExperts and use it to set several properties to false - >> basically any of the TEDB... stuff. I have also used "engStraw.Close" as the first line of the data module's on create but the results haven't always been entirely predictable ... |
Mon, Mar 16 2009 3:46 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Peter,
<< Interestingly (perhaps), it is the connection to the session that throws the error (sesStraw.Connected := true). The preceding "engStraw.Active:=True" doesn't cause a problem. If I set a breakpoint in the Engine.BeforeStart, this does not fire. >> So, you're saying that the BeforeStart event handler is not firing for the TEDBEngine component when the Engine's Active property is set to True ? -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Mar 16 2009 4:24 PM | Permanent Link |
Peter Thorne | "Tim Young [Elevate Software]" wrote:
<< So, you're saying that the BeforeStart event handler is not firing for the TEDBEngine component when the Engine's Active property is set to True ? >> Well, that would appear to be the case. With my code in the OP, if I set breakpoints at "ExeLocation := ExtractFilePath(Application.ExeName); " in the OnCreate and "ConfigPath := ExeLocation;" in the BeforeStart, the latter does not fire before I get the 409 when I execute "sesStraw.Connected:=True;" in the OnCreate event. I would not have expected this I guess but then maybe Roy has a point when he talks about the order of events firing in Delphi not always being totally predictable ... ? |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |