Помогите с DLL на Delphi

 
Привет!
Данная выбивает через какоето время терминал! Помогите найти ошибки и исправить их.

Код ДЛЛ:
...........................
library mydll;
uses
 ShareMem, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ADODB,  StdCtrls, ActiveX;

var
Conn: TADOConnection;
Cmd: TADOCommand;

{$R *.res}

procedure SQLConnect(); stdcall;

begin
    CoInitialize(Nil);
 try
  Conn := TADOConnection.Create(nil);
  Cmd := TADOCommand.Create(nil);

  Conn.LoginPrompt := False;
  Conn.ConnectionString := 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=fx;Data Source=it_ld_big';
  Conn.Connected := True;
  Cmd.Connection:=Conn;

finally

 end;
 CoUninitialize;
end;

procedure SQLDisconnect(); stdcall;
begin
    CoInitialize(Nil);
 try
  Conn.Close;
finally
  Conn.Free;
  cmd.Free;
 end;
 CoUninitialize;
end;

function SQLExecute(sCmd: Pchar):boolean; stdcall;
begin
    CoInitialize(Nil);
 try
  cmd.CommandText:=sCmd;
  cmd.Execute;
finally

 end;
 CoUninitialize;
 SQLExecute:=true;
end;

function SQLState():boolean; stdcall;
begin
try
if (stClosed in Conn.State) then
    SQLState:=false
else
    SQLState:=true;
except
      on E : Exception do
     begin
       ShowMessage('Exception class name = '+E.ClassName);
       ShowMessage('Exception message = '+E.Message);
     end;
   end;

end;

exports
 SQLConnect,
 SQLDisconnect,
 SQLExecute,
 SQLState;
begin
end.


...........................

Код эксперта:
#import "mydll.dll"
void SQLConnect();
void SQLDisconnect();
bool SQLExecute(string sCmd);
bool SQLState();
#import
..

int start()
{
...

SQLConnect();
SQLExecute("UPDATE ClearingFarm SET [date] = { fn NOW() }, ask = "+ Ask +", bid = "+ Bid +", isallowed "+IsTradeAllowed()+" WHERE (broker_id = 5)");
SQLDisconnect();
}
...


Спасибо!

Причина обращения: