Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 6 of 6 total |
ElevateDB Error #409 |
Sat, Sep 16 2017 5:58 PM | Permanent Link |
KimHJ Comca Systems, Inc | After I change all my table into Create in code I get the following error when I open the table. Error #409 the second time the module get a request.
procedure TEWBModule1.PrepareConnection; begin if not assigned(ComcaSession) then begin ComcaSession := PrepareSession; end; if not assigned(AllStoreDatabase) then begin AllStoreDatabase := AllPrepareDatabase(ComcaSession); end; end; function TEWBModule1.PrepareSession: TEDBSession; begin Result := TEDBSession.Create(nil); Result.AutoSessionName := true; Result.SessionType := stRemote; Result.LoginUser := 'User'; Result.LoginPassword := 'Pass'; Result.Open; end; function TEWBModule1.AllPrepareDatabase(const ThreadSession: TEDBSession):TEDBDatabase; begin Result := TEDBDatabase.Create(nil); Result.DataBase := 'AllStores'; Result.DatabaseName := 'ComcaStores'; Result.SessionName := ThreadSession.SessionName; Result.Connected := True; end; First request goes to this Function i goes here to see if any print jobs. It works first time after the Webserver have been started. PrepareConnection; AllStoresTbl:= TEDBTable.Create(nil); with AllStoresTbl do begin SessionName := ComcaSession.SessionName; DatabaseName := AllStoreDatabase.DatabaseName; TableName := 'AllCleaners'; Readonly := True; IndexFieldNames := 'CloudPrnt'; Open; end; if AllStoresTbl.FindKey([TempStore]) then begin StoreDatabase := PrepareDatabase(ComcaSession, Trim(AllStoresTbl.FieldByName('Database').AsString)); StoreDatabase.Connected := True; MainActivityTbl := TEDBTable.Create(nil); with MainActivityTbl do begin SessionName := ComcaSession.SessionName; DatabaseName := StoreDatabase.DatabaseName; TableName := 'MainActivity'; Readonly := False; IndexFieldNames := 'DateIn;TimeIn'; Filter := 'Printed < 2'; Open; Filtered := True; end; MainActivityTbl.Close; MainActivityTbl.Free; end; AllStoresTbl.Close; StoreDatabase.Free; AllStoresTbl.Free; ComcaSession.Free; The if there is print job the second request goes to this function, Here I get the #409 error everytime. PrepareConnection; MasterRTbl := TEDBTable.Create(nil); with MasterRTbl do begin SessionName := ComcaSession.SessionName; DatabaseName := AllStoreDatabase.DatabaseName; TableName := 'AllCleaners'; Readonly := True; IndexFieldNames := 'CloudPrnt'; Open; end; if MasterRTbl.FindKey([MacId]) then begin CDatabase := Trim(MasterRTbl.FieldByName('Database').AsString); MasterRTbl.Close; EachStoreDatabase := PrepareDatabase(ComcaSession, CDatabase); EachStoreDatabase.Connected := True; ActivityTbl := TEDBTable.Create(nil); ActivityTbl.SessionName := ComcaSession.SessionName; ActivityTbl.DatabaseName := EachStoreDatabase.DatabaseName; ActivityTbl.TableName := 'MainActivity'; ActivityTbl.Open; ............................ ActivityTbl.Close; ActivityTbl.Free; MasterRTbl.Free; AllStoreDatabase.Connected := False; AllStoreDatabase.Free; ComcaSession.Free; Thanks for any help. Kim |
Sun, Sep 17 2017 3:17 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | KimHJ
From the manual EDB_ERROR_CONFIG (409) There is an error in the configuration (<ErrorMessage>)This error is raised whenever there is an error in the configuration. The specific error message is indicated within the parentheses. Two questions: 1. is there any additional information about the error 2. You say "The if there is print job the second request goes to this function, Here I get the #409 error everytime." then give a lot of code but no indication where the error is actually raised. Can you indicte the line please. Roy Lambert |
Mon, Sep 18 2017 3:59 AM | Permanent Link |
Matthew Jones | KimHJ wrote:
> if not assigned(ComcaSession) then > ComcaSession.Free; This is one of those cases which I believe makes the case for FreeAndNil completely. Some consider it a "code smell", but I have always been of the opinion that it is better to have the code go bang as soon as possible in development than get out into the wild. Now, here you start by seeing if the session is assigned, and if not, you create it. And at the end, you free the session, but you don't set it to be nil, so the second time around you will not create it, but you will instead reference the dead object instance, and who knows what may be left around. Make those FreeAndNil(ComcaSession); all over and see if it shows the real problem, or more likely fixes it. (There is a great book, or at least it was in its time, called "Writing Solid Code". One place I worked we always gathered around any bug that we got caught by and tried to work out what we could do to make sure we never fell over that bug again. And FreeAndNil is one such practice. Usually not necessary, it ensures that if you do come along and reference an object after you free'd it, you know immediately.) -- Matthew Jones |
Mon, Sep 18 2017 4:41 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Matthew
You may well be right - it depends on where the error happens. I was more wondering why he bothers to free the session etc if he needs to use it later on and was thinking it may be in a different unit, thread or something. Roy Lambert |
Tue, Sep 19 2017 4:59 PM | Permanent Link |
KimHJ Comca Systems, Inc | "Matthew Jones" wrote:
<< Make those FreeAndNil(ComcaSession); all over and see if it shows the real problem, or more likely fixes it. >> Thanks Matthew that did it. Kim |
Tue, Sep 19 2017 5:03 PM | Permanent Link |
KimHJ Comca Systems, Inc | Roy Lambert wrote:
<<Matthew You may well be right - it depends on where the error happens. I was more wondering why he bothers to free the session etc if he needs to use it later on and was thinking it may be in a different unit, thread or something.>> This is a module, so maybe I don't need to free it since after the module run it will free it self and second request will be a new instant of the module. Except when I debug. Kim |
This web page was last updated on Tuesday, September 17, 2024 at 04:19 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |