what is the error message?

    I have never used TComponentType.Create(nil) in a with clause... I don't
know but this might be it, can you try to avoid it? or maybe it's the nil
parameter that you are passing to the constructor... can you try application
for example?

    The error message would help us more to find out the source of your
problem

Cheers
Vahan

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of Chris @ IT
Sent: Tuesday, July 05, 2005 2:23 PM
To: [email protected]
Subject: [delphi-en] Borland ADO and Threads


Hi all,

Im having a slight problem here; probably missing something small.
I have an application that recieves sms messages from an smpp server then
spins of a thread that goes ahead to insert into a database. Reason for this
is that i need to free my application as soon as possible to receive the
next smpp message coming in.

This works all well and good - i ensured that i call coinitialize and
couninitialize for each thread (so that i can use com objects (TADOCommand))

The problem comes when i drop a timer and on each timer tick i cannot create
any kind of com/activex object (ado etc etc) if i try i get the following
error

The application called an interface that was marshalled for a different
thread

below are snips of the code

- for the thread execute method itself

procedure Tinsert.Execute;
begin
  { Place thread code here }
  Coinitialize(nil);

  with TADOCOmmand.Create(nil) do
  begin
    ConnectionString:='Provider=SQLOLEDB.1;Password=kiokor$7;Persist
Security Info=True;User ID=sa;Initial Catalog=smsgate';

    CommandText:='insert into tblincoming
(Message_Destination,Message_Source,Message_Text,Message_Option,Message_SMSC
TimeStamp,Message_Validity) values ('+
      QuotedStr(f_bstrDestination)+','+
      QuotedStr(f_bstrOriginator)+','+
      QuotedStr(f_bstrMessage)+','+
      IntToStr(f_lOption)+','+
      QuotedStr(FormatDateTime('dd mmm yyyy HH:nn:ss',f_SMSCTimeStamp))+','+
      QuotedStr(FormatDateTime('dd mmm yyyy HH:nn:ss',f_Validity))+')';

    Execute;
    Free;
  end;

  CoUninitialize;
end;

- and for the timer method - smpp send

procedure TsSMPP.TimerTimer(Sender: TObject);
begin

  with TADOQUery.Create(nil) do
  begin
    ConnectionString:='Provider=SQLOLEDB.1;Password=kiokor$7;Persist
Security Info=True;User ID=sa;Initial Catalog=smsgate';
    SQL.TexT:='select * from tbloutgoing where Message_MTDelivered=0';

    Open;
    while not EOF do
    begin
      SMPP.SMSCSubmitMessage(
        FieldByName('Message_Destination').AsString,
        FieldByName('Message_Source').AsString,
        FieldByName('Message_Option').AsInteger,
        FieldByName('Message_SourceTON').AsInteger,
        FieldByName('Message_SourceNPI').AsInteger,
        FieldByName('Message_DestTON').AsInteger,
        FieldByName('Message_DestNPI').AsInteger,
        FieldByName('Message_Text').AsString,
        Now,
        FieldByName('Message_Validity').AsInteger);

      Edit;
      FieldByName('Message_MTDelivered').AsBoolean:=True;
      Post;
      Next;
    end;
    Close;
  end;

end;

the error occurs on the timer send as soon as the ado querry is created

any help would be appreciated.

regards

Chris.



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]



----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS

  a..  Visit your group "delphi-en" on the web.

  b..  To unsubscribe from this group, send an email to:
   [EMAIL PROTECTED]

  c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


----------------------------------------------------------------------------
----




[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to