Board index » delphi » Problems about Multi-Threading connections (several instances of object TDatabase)

Problems about Multi-Threading connections (several instances of object TDatabase)

Hi,

I try to loop on the method RunTimeDbCreate
and an error occured at the eleventh pass : Not enough memory Alias base 11
----------------------------------------------------------------------------
------
            for i := 0 to 12 do
                UserData[indexTerm].dataBase :=
unTimeDbCreate( 'base'+IntToStr(i),

'session'+IntToStr(i),

Database1.AliasName);
            end;

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

As my understanding, the problem comes from the call of method
OpenDatabase(DatabaseName)

function TForm1.RunTimeDbCreate(const DatabaseName, SessionName, AliasName:
String): TDatabase;
var
  TempDatabase: TDatabase;
begin
  TempDatabase := nil;
  try
    { If the session exists, make it active; if not, create a new session }
    Sessions.OpenSession(SessionName);
    with Sessions do
      with FindSession(SessionName) do begin
        Result := FindDatabase(DatabaseName);
        if (Result = nil) then begin
          { Create a new database component }
          TempDatabase := TDatabase.Create(nil);
          TempDatabase.DatabaseName := DatabaseName;
          TempDatabase.SessionName := SessionName;
          TempDatabase.KeepConnection := True;
          TempDatabase.LoginPrompt := False;
          TempDatabase.Params.Add('USER NAME=toto');
          TempDatabase.Params.Add('PASSWORD=****);
          TempDatabase.Params.Add('USERNAME=tata');
          TempDatabase.AliasName := AliasName;
        end;

Quote
>>>>>        Result := OpenDatabase(DatabaseName);           <<<<<

      end;
  except
    TempDatabase.Free;
    raise;
  end;
end;

Thks

 

Re:Problems about Multi-Threading connections (several instances of object TDatabase)


Hi,

- Try to increase memory params in you BDE settings (in BDE
admin\configuration\System\INIT)

- use only one DB and do what you want to do in each tread using this DB

Hope this will help you

Cedric

"Nicolas Rey-Cnevaz" <nicolas....@whynot.fr> a crit dans le message news:
3da1b822$0$6125$626a5...@news.free.fr...

Quote
> Hi,

> I try to loop on the method RunTimeDbCreate
> and an error occured at the eleventh pass : Not enough memory Alias base
11
> --------------------------------------------------------------------------
--
> ------
>             for i := 0 to 12 do
>                 UserData[indexTerm].dataBase :=
> unTimeDbCreate( 'base'+IntToStr(i),

> 'session'+IntToStr(i),

> Database1.AliasName);
>             end;

> --------------------------------------------------------------------------
--
> ------

> As my understanding, the problem comes from the call of method
> OpenDatabase(DatabaseName)

> function TForm1.RunTimeDbCreate(const DatabaseName, SessionName,
AliasName:
> String): TDatabase;
> var
>   TempDatabase: TDatabase;
> begin
>   TempDatabase := nil;
>   try
>     { If the session exists, make it active; if not, create a new
session }
>     Sessions.OpenSession(SessionName);
>     with Sessions do
>       with FindSession(SessionName) do begin
>         Result := FindDatabase(DatabaseName);
>         if (Result = nil) then begin
>           { Create a new database component }
>           TempDatabase := TDatabase.Create(nil);
>           TempDatabase.DatabaseName := DatabaseName;
>           TempDatabase.SessionName := SessionName;
>           TempDatabase.KeepConnection := True;
>           TempDatabase.LoginPrompt := False;
>           TempDatabase.Params.Add('USER NAME=toto');
>           TempDatabase.Params.Add('PASSWORD=****);
>           TempDatabase.Params.Add('USERNAME=tata');
>           TempDatabase.AliasName := AliasName;
>         end;
> >>>>>        Result := OpenDatabase(DatabaseName);           <<<<<
>       end;
>   except
>     TempDatabase.Free;
>     raise;
>   end;
> end;

> Thks

Other Threads