Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread #300 error
Wed, Nov 25 2009 12:34 PMPermanent Link

"Sorin H"
The issue was raise in the past but I can't find a suitable answer.

Basically I want to open the app. from 2 or more comp. but the error
"#300 canot lock.. for exclusive access" appear even when I try to open a
second session on the same comp.

On the main datamodule create method I have the folling lines:

"with engMain do
 begin
   ConfigPath:=ExtractFilePath(ParamStr(0));
   TempTablesPath := GetTempTablesPath;
   ConfigurationQuery.SQL.Text := 'ALTER DATABASE "Manui" PATH '+
               Engine.QuotedSQLStr(ConfigPath+'Data');
   ConfigurationQuery.ExecSQL;
 end;"

What am I missing?
Thank
Sorin

Wed, Nov 25 2009 1:38 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin

You can't alter the database whilst its open in another app.  Try wrapping the code in a try .. except block and raise an exception to warn the user if you can't alter it.

Roy Lambert [Team Elevate]


Thu, Nov 26 2009 3:19 AMPermanent Link

"Sorin H"
I remember I saw a general instruction for working on multiuser mode with
local database
Can you redirect me to this?

Thanks Sorin

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:09986960-AA2E-456A-9895-2B419E5F1C0B@news.elevatesoft.com...
> Sorin
>
> You can't alter the database whilst its open in another app. Try wrapping
> the code in a try .. except block and raise an exception to warn the user
> if you can't alter it.
>
> Roy Lambert [Team Elevate]
>
>
>

Thu, Nov 26 2009 4:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin

>I remember I saw a general instruction for working on multiuser mode with
>local database
>Can you redirect me to this?

Sorry no.

Roy Lambert [Team Elevate]
Sun, Nov 29 2009 4:22 AMPermanent Link

"Sorin H"

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
>
> You can't alter the database whilst its open in another app. Try wrapping
> the code in a try .. except block and raise an exception to warn the user
> if >you can't alter it.

Ok I change to:
"try
 with engMain do
 begin
   ConfigPath:=ExtractFilePath(ParamStr(0));
   TempTablesPath := GetTempTablesPath;
   ConfigurationQuery.SQL.Text := 'ALTER DATABASE "Manui" PATH '+
               Engine.QuotedSQLStr(ConfigPath+'Data');
   ConfigurationQuery.ExecSQL;
 end;
except
end;"

It solve the error problem but, when a second user run this code and the
database is already open,
it takes about 90 seconds.
To open this first it takes 1 second?

Thanks Sorin

Sun, Nov 29 2009 4:51 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin

>Ok I change to:
>"try
> with engMain do
> begin
> ConfigPath:=ExtractFilePath(ParamStr(0));
> TempTablesPath := GetTempTablesPath;
> ConfigurationQuery.SQL.Text := 'ALTER DATABASE "Manui" PATH '+
> Engine.QuotedSQLStr(ConfigPath+'Data');
> ConfigurationQuery.ExecSQL;
> end;
>except
>end;"
>
>It solve the error problem but, when a second user run this code and the
>database is already open,
>it takes about 90 seconds.
>To open this first it takes 1 second?

Try this as an approach (totally untested)

function SetUpDBPath(const PathWanted:string):boolean;
begin
ConfigurationQuery.SQL.Text := 'SELECT Path FROM Databases WHERE Name = ' + QuotedStr('Manui');
ConfigurationQuery.ExecSQL;
if LowerCase(ConfigurationQuery.FieldByName('Path').AsString) <> LowerCase(PathWanted) then begin
 Result := False;
 try
  ConfigurationQuery.Close;
  ConfigurationQuery.SQL.Text := 'ALTER DATABASE "Manui" PATH '+ QuotedStr(PathWanted);
  ConfigurationQuery.ExecSQL;
  Result := True;
 except
  Result := False;
 end;
end else Result := True;
ConfigurationQuery.Close;
end;

Roy Lambert [Team Elevate]
Sun, Nov 29 2009 12:26 PMPermanent Link

"Sorin H"
>
> Try this as an approach (totally untested)
>
> function SetUpDBPath(const PathWanted:string):boolean;
> begin
> ConfigurationQuery.SQL.Text := 'SELECT Path FROM Databases WHERE Name = '
> + QuotedStr('Manui');
> ConfigurationQuery.ExecSQL;
> if LowerCase(ConfigurationQuery.FieldByName('Path').AsString) <>
> LowerCase(PathWanted) then begin
> Result := False;
> try
> ConfigurationQuery.Close;
> ConfigurationQuery.SQL.Text := 'ALTER DATABASE "Manui" PATH '+
> QuotedStr(PathWanted);
> ConfigurationQuery.ExecSQL;
> Result := True;
> except
> Result := False;
> end;
> end else Result := True;
> ConfigurationQuery.Close;
> end;

After a small modification:
first ocurrence of :  ConfigurationQuery.ExecSQL;  replace with
ConfigurationQuery.Open;
it's look much better

Thanks Sorin

Roy sorry for the replay to your email.

Image