Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Mixing Local and Remote Sessions in same thread
Thu, May 23 2013 10:56 AMPermanent Link

John Taylor

Using DBIsam 4.35 client server.

In a thread I want to update a remote table on the server in one procedure
and in another procedure I want to update a local table.  The database
server is running and the function to update the remote table works fine.  I
am running into a very strange issue when attempting to update the local
table using a local session.

I quoted the procedure down to the line causing the error.  My question is
1) why would an exception be thrown in Q.Sql.Add(......) ??!!, and 2) What
the heck does this have to do with the database server, this is a Session
with SessionType set to stLocal ?

Can anyone spot what I have done wrong ?

Here is my procedure:

procedure TSubmitManThread.SaveLocalData(p : pFaxSubmitRecord;index :
integer;Saved : boolean = true);
var
 S : TDBIsamSession;
 D : TDBIsamDatabase;
 Q : TDBIsamQuery;
 TableName : AnsiString;
 HaveBlob : boolean;
 pd : pSubmitDetail;
 dDate, dTime : TDateTime;
begin
     HaveBlob := FileExists(p^.sAPFZipFile);// sLocalTifFile);
     TableName := 'Table_OutGoing.sfdata';
     pd := p^.sDetailList[index];
     S := TDBIsamSession.Create(nil);
     S.AutoSessionName := true;
     S.PrivateDir := FLocalPath;//This is c:\users\JT\AppData\Local\Data
     S.SessionType := stLocal;
     D := TDBIsamDataBase.Create(nil);
     D.DataBaseName := '_LocalData';
     D.SessionName := S.SessionName;
     D.Directory := FLocalPath;
     Q := TDbIsamQuery.Create(nil);
     try
       Q.SessionName := S.SessionName;
       S.Active := true;
       D.Connected := true;
       Q.DatabaseName := D.DataBaseName;
       Q.RequestLive := true;
       Q.Sql.Add('INSERT INTO ' + AnsiQuotedStr(TableName,'"'));
       Q.Sql.Add('(');
       Q.Sql.Add('OFT_DATE_SENT,OFT_TIME_SENT,OFT_FAXRESULT,OFT_RECIPIENT,OFT_COMPANYNAME,OFT_FAXNUMBER,OFT_ROUTING,OFT_PAGES');
       Q.Sql.Add(',OFT_COVERNAME,OFT_COVERTITLE,OFT_COVERMEMO,OFT_COVERSENDER,OFT_COVERACTION,OFT_FROMQUEUE');
       Q.Sql.Add(',FOLDER,OFT_JOB_KEY,SUBMIT_ID,OFT_MEMO,OFT_BILLCODE,OFT_GROUP');
       if HaveBlob then
        Q.Sql.Add(',OFT_TIFBLOB');
       Q.Sql.Add(')');
       Q.Sql.Add('VALUES(');
       Q.Sql.Add('Tongueate,Tongueime,Tongueesult,Tongueecipient,Tongueompany,TongueaxNumber,Tongueouting,Tongueages,TongueoverName,TongueoverTitle,TongueoverMemo');

       //exception thrown on the line above
       //EDBIsamEngineError.ErrorCode = 11294
       //E.Message = 'DBISAM Engine Error # 11294 The database
'JOHNTAYLOR-LAP\SFSERVER3' does not exist on the database server at
'JOHNTAYLOR-LAP''

end;


Thanks for any help

JT
Thu, May 23 2013 11:21 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

John


Have you tested the code in a non-threaded context? Moving it into the foreground makes it much easier to debug Smiley

Since I don't use DBISAM these years I can't remember if the problem that existed with params was fixed (I think so but I'm not sure) if not it's worth trying creating the sql into a stringlist and then have Q.SQL.Text := stringlist.Text

Final point - what is the exception?

Roy Lambert
Thu, May 23 2013 12:11 PMPermanent Link

John Taylor

Roy,

I have another run away thread that is actually throwing an exception during
my debugging, I believe the exception is there and not in the thread I'm
looking at.  This was so bizarre, I should have suspected the unexpected Smile

I think I have a handle on it now.

Thanks

John

"Roy Lambert" <roy@lybster.me.uk> wrote in message
news:27658568-12B0-4595-8F62-D9598EB46198@news.elevatesoft.com...
> John
>
>
> Have you tested the code in a non-threaded context? Moving it into the
> foreground makes it much easier to debug Smiley
>
> Since I don't use DBISAM these years I can't remember if the problem that
> existed with params was fixed (I think so but I'm not sure) if not it's
> worth trying creating the sql into a stringlist and then have Q.SQL.Text
> := stringlist.Text
>
> Final point - what is the exception?
>
> Roy Lambert
>
Thu, May 23 2013 1:08 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

John


>I have another run away thread that is actually throwing an exception during
>my debugging, I believe the exception is there and not in the thread I'm
>looking at. This was so bizarre, I should have suspected the unexpected Smile

I can well believe that. In the mainform for a threaded app I have {.$DEFINE NOALARMCHECKS} and then all the creation / usage code is wrapped in {$IFDEF NOALARMCHECKS}{$ENDIF}

Its reason why my main suggestion was to test in the foreground.

>I think I have a handle on it now.

Good

Roy Lambert [Team Elevate]
Image