Использование TADOConnection в секции инициализации DLL
От: Morozov Россия  
Дата: 16.03.05 12:22
Оценка:
Hi All,

Есть такой код:
====================================

library Integr;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Windows,
  Classes,
  ActiveX,
  ADODB;

var
  MDBFileName : String;
  acMain : TADOConnection;
  cUpdate : TADOCommand;

begin
  try
    MDBFileName := ChangeFileExt(ParamStr(0), '.mdb');
    if FileExists(MDBFileName) then begin

      CoInitialize(nil);
      try

        acMain := TADOConnection.Create(nil);
        try
          acMain.ConnectionString :=
            Format('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Persist
Security Info=False;Jet OLEDB:Database Password=commonpas;Jet OLEDB:Engine
Type=5', [MDBFileName]);
//            acMain.Mode := cmReadWrite;
//            acMain.IsolationLevel := ilReadCommitted;
//            acMain.KeepConnection := False;
            acMain.LoginPrompt := False;
            acMain.ConnectOptions := coAsyncConnect;

            acMain.Open;
            try
              cUpdate := TADOCommand.Create(nil);
              try
                cUpdate.Connection := acMain;
  //              cUpdate.CommandText := 'select * from PricesData';
  //              cUpdate.Execute;
              finally
                cUpdate.Free;
              end;

            finally
              acMain.Close;
            end;

        finally
          acMain.Free;
        end;

      finally
        CoUninitialize;
      end;
      
    end;
  except
    on E : Exception do begin
      OutputDebugString(PChar(E.Message));
    end;
  end;
end.

====================================

Почему при вызове acMain.Close; происходит ступор приложения: приложение
останавливается в дебрях acMain.Close и начинает занимать 100% загрузки
процессора?

Заранее благодарен.

С уважением, Морозов Сергей.
С уважением,
Морозов Сергей.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.