Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 17 total
Thread Best Way to Alter Database Path.
Wed, May 9 2018 7:01 AMPermanent Link

Steve Gill

Avatar

When I try to alter an existing database in code I always get an error: "ElevateDB Error #300 Cannot lock the database My Database for exclusive access"

  SQL := 'ALTER DATABASE "My Database" PATH ' + DBEngine.QuotedSQLStr(ADatabasePath);
  DBSession.Execute(SQL);

If I alter the database in EDB Manager by right-clicking on the database and selecting Alter Database it works fine.

Both the config and catalog files exist.  Nothing else is using the database.

Any suggestions?

= Steve
Wed, May 9 2018 12:48 PMPermanent Link

Terry Swiers

Hi Steve,

> When I try to alter an existing database in code I always get an error: "ElevateDB Error #300 Cannot lock the database My Database for exclusive access"

Sounds like you might be trying to change the path to the database that you currently have open.   Make sure that you close all connections to the database (including the one you are using to access it) and call the alter statement from the TEDBSession.Execute(...) rather than from a TEDBQuery.

Terry
Wed, May 9 2018 2:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Steve,

<< When I try to alter an existing database in code I always get an error: "ElevateDB Error #300 Cannot lock the database My Database for exclusive access" >>

Is this 2.28 or earlier, and are you using the new buffered file I/O ?

Tim Young
Elevate Software
www.elevatesoft.com
Wed, May 9 2018 4:17 PMPermanent Link

Steve Gill

Avatar

Hi Terry,

<< Sounds like you might be trying to change the path to the database that you currently have open.   Make sure that you close all connections to the database (including the one you are using to access it) and call the alter statement from the TEDBSession.Execute(...) rather than from a TEDBQuery.>>

I'm already using TEDBSession.Execute and the database is closed.

= Steve
Wed, May 9 2018 4:30 PMPermanent Link

Steve Gill

Avatar

Hi Tim,

<< Is this 2.28 or earlier, and are you using the new buffered file I/O ? >>

It's 2.28 but I'm not using the new buffered file I/O at this point in the process.

The application is installed with a blank database by a setup program set to a default location.  This has worked fine for years but some users now want to be able to install the database somewhere else.  So I'm writing a small application that will be called by the setup program *if* the user specifies a different local drive and/or directory.  The application will alter the database so that the path is set to the different location.  This is the point where I'm having problems.  Nothing is connected to the database.

After that's all done the server service will then use the buffered file I/O when it starts up.

The application always get the Error 300.  If I run the same SQL in EDB Manager it also gets the Error 300, *but* if I use the built-in Alter Database feature in EDB Manager it works fine for some reason, ie. click on the database and select Alter Database from the menu.  So I'm guessing I must be doing something wrong although what that is I don't know.

Thanks.

= Steve
Thu, May 10 2018 4:27 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Steve


Is the database open when you try this? If so close it.

Roy Lambert
Thu, May 10 2018 4:37 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Steve


Have a look at SQL history (Explorer | SQL History) and look for the command you executed through the built in dialog. Open that in a new sql window and see what happens.

Roy Lambert
Thu, May 10 2018 6:11 AMPermanent Link

Steve Gill

Avatar

Hi Roy,

<< Is the database open when you try this? If so close it. >>

It's closed.

= Steve
Thu, May 10 2018 6:15 AMPermanent Link

Steve Gill

Avatar

Hi Roy,

<< Have a look at SQL history (Explorer | SQL History) and look for the command you executed through the built in dialog. Open that in a new sql window and see what happens.>>

Already tried that and I get the same error message. The only way I can get it to work without error is by using the Alter Database dialog.

= Steve
Thu, May 10 2018 6:22 AMPermanent Link

Adam Brett

Orixa Systems

Steve

Is it possible instead to create a second database at the new location, backup the existing one, restore it to the new location, then close the session, and change its path to the new location.

You end up with 2 copies of the database, one at the new location that the user wants.

Once the new database is set up, you can delete the old one.

Adam
Page 1 of 2Next Page »
Jump to Page:  1 2
Image