Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 24 total
Thread restore error
Thu, Apr 3 2008 4:34 PMPermanent Link

Nirlan
Delphi 2007 win32
ElevateDB 1.09 Build 1

I am doing some testing with the elevatedb and am having problems at the moment to restore
a backup.
   
I get the error message:

ElevateDB error#300.cannot lock database ESTOQUE6DB for exclusive access.

How do I get access exclusive to the database ?
Thu, Apr 3 2008 4:38 PMPermanent Link

Lance Rasmussen

Jazzie Software

Avatar

Team Elevate Team Elevate

Do you have another session actively connected to that database from a
different program running?

Lance


"Nirlan" <nirlan@mtg.com.br> wrote in message
news:8C1E69F2-5B7B-4594-A31B-C0486D02303E@news.elevatesoft.com...
> Delphi 2007 win32
> ElevateDB 1.09 Build 1
>
> I am doing some testing with the elevatedb and am having problems at the
> moment to restore
> a backup.
>
> I get the error message:
>
> ElevateDB error#300.cannot lock database ESTOQUE6DB for exclusive access.
>
> How do I get access exclusive to the database ?
>
Fri, Apr 4 2008 1:01 PMPermanent Link

Nirlan

> Do you have another session actively connected to that database from a
> different program running?

   
I do not have another active session.
I am using this:


procedure TForm1.FormCreate(Sender: TObject);
begin
 EDBengine1.Active                := False;
 EDBengine1.ConfigPath         := ExtractFilePath( Application.ExeName );
 EDBengine1.TempTablesPath := ExtractFilePath( Application.ExeName );
 EDBengine1.Active                := True ;

 Database1.Open;
end;


procedure TForm1.EDBEngine1AfterStart(Sender: TObject);
var
 Session: TEDBSession;

begin
 Session := Engine.FindSession('Default');
 Session.RecordLockProtocol := lpPessimistic;

 if Assigned(Session) then
 begin
   Session.LoginUser        := 'Administrator';
   Session.LoginPassword := 'EDBDefault';
 end;
end;


procedure TForm1.BotaoRestoreClick(Sender: TObject);
var
 vBackupFile : String;
 vBackupPath : String;
 Session     : TEDBSession;

begin
 vBackupPath  := ExtractFilePath( Application.ExeName );
 vBackupFile   := Edit1.Text;

  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add( 'Restore Database Estoque6DB '  );
  Query1.SQL.Add( 'From ' + #34 + vBackupFile + #34 );
  Query1.SQL.Add( 'In '   + #39 + vBackupPath + #39 );
  Query1.SQL.Add( 'include Catalog ' );
  Query1.ExecSQL;
end;
Fri, Apr 4 2008 2:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Nirlan,

<<  Database1.Open; >>

This is your issue.  Restoring a database is a session-level statement that
requires exclusive access to the database being restored, meaning that you
can't have the database open elsewhere in your application if you need to
perform a restore.  The reason for this is simple - you could restore a
completely different catalog that would cause any open tables, etc. to use a
completely different table structure, which would cause AVs and errors
everywhere once the restore was complete.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Apr 5 2008 11:41 AMPermanent Link

Nirlan
Now I am closing the database.
But the error continues. Any suggestions?


procedure TForm1.BotaoRestoreClick(Sender: TObject);
var
vBackupFile : String;
vBackupPath : String;

begin

 Database1.Close;     // new row

vBackupPath  := ExtractFilePath( Application.ExeName );
vBackupFile   := Edit1.Text;

 Query1.Close;
 Query1.SQL.Clear;
 Query1.SQL.Add( 'Restore Database Estoque6DB '  );
 Query1.SQL.Add( 'From ' + #34 + vBackupFile + #34 );
 Query1.SQL.Add( 'In '   + #39 + vBackupPath + #39 );
 Query1.SQL.Add( 'include Catalog ' );
 Query1.ExecSQL;
end;
Sat, Apr 5 2008 2:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Nirlan,

<< Now I am closing the database. But the error continues. Any suggestions?
>>

Are you running this in the IDE ?  Do you have any TEDB* components open at
design-time ?  Somewhere in your application or elsewhere, the database is
open.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jul 1 2009 11:14 AMPermanent Link

Tasos Savva
I have exactly the same problem and I run the following code just to find if any connection is open

===============================
 for i:=0 to EDBSession1.DatabaseCount-1 do begin
   if EDBSession1.Databases[i].Connected then
     MessageDlg(IntToStr(i) + ' ' + EDBSession1.Databases[i].DatabaseName, mtInformation, [mbok], 0);
   EDBSession1.CloseDatabase(EDBSession1.Databases[i]);
 end;

 for i:=0 to EDBEngine1.SessionCount-1 do
   if EDBEngine1.Sessions[i].Connected then
     MessageDlg(IntToStr(i) + ' ' + EDBEngine1.Sessions[i].SessionName, mtInformation, [mbok], 0);
===============================
I only get the session that i use in the software and no open databases.

it must something else i guess

can you please help me?
Wed, Jul 1 2009 5:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tasos,

<< I only get the session that i use in the software and no open databases.
>>

Is your application single-user, or are there other users/sessions using the
same database ?  Also, are you running the application in the IDE ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jul 1 2009 8:54 PMPermanent Link

Pete Hollyer
Tim

I hate to join the band wagon...but with 2.02B14 I ahve the same problem.
Its a local database (not server)
I nomally have 1 static connection used in the application...I close him and even set him to NULL...then build a new connection..create the
Store...then try and restore the backup and I keep getting this 300 cannot get exclusive access to data base...here is my c# code


               //get exclusive control of DB (killing static connection)
               EDBCCon = getConnection();
               EDBCCon.Close();
               EDBCCon = null;

               //make my NEW connection
               EDBConnection DBConn;

               EDBConnectionStringBuilder csb = new EDBConnectionStringBuilder();
               csb.Name = "ListBuilderConnection";
               csb.Description = "ListBuilder Connection Object";
               csb.Type = "LOCAL";
               csb.ConfigPath = WorkAppPath.AppPath + "\\Database";
               csb.Database = "ListBuilder";
               csb.UID = "Administrator";
               csb.PWD = "EDBDefault";

               DBConn = new EDBConnection(csb.ConnectionString);
               EDBCommand dbCommand = new EDBCommand();
               DBConn.ChangeDatabase("Configuration");
               DBConn.Open();

               //Create Store
               SQL = "CREATE STORE Backups";
               SQL += " as LOCAL PATH '" + WorkAppPath.AppPath + "\\Backups' ";
               SQL += " DESCRIPTION 'ListBuilder Database Backup " + DateTime.Now.ToShortDateString() + "' ";

               dbCommand = new EDBCommand(SQL, DBConn);
               dbCommand.ExecuteNonQuery();

               char chrQuote = (char)34;

               //close this connection
               DBConn.Close();
              
               //now reopen for restore
               DBConn.Open();

               SQL = "RESTORE DATABASE ListBuilder ";
               SQL += " FROM " + chrQuote + FileName+ ".EDBBkp" + chrQuote;
               SQL += " IN STORE Backups"  ;
               SQL += " INCLUDE CATALOG ";
               dbCommand = new EDBCommand(SQL, DBConn);
               dbCommand.ExecuteNonQuery();
Wed, Jul 1 2009 9:56 PMPermanent Link

Pete Hollyer

One additional observation about this error 300....I get the SAME error if looks like this:

SQL = "RESTORE DATABASE ListBuilder ";
SQL += " FROM " + "\"lkjasldkjasd\"";

where the FROM file name does NOT exist...I would have anticipated that to be a different error...but who knows?

Pete
Page 1 of 3Next Page »
Jump to Page:  1 2 3
Image