Error Restoring: Logical File Name Already In Use (slightly different behaviour)

Continuing the discussion from Error Restoring: Logical File Name Already In Use:

I got same problem today in 5.1.56, using LocalDB. I already have the Allow overwrite... setting enabled. After the error, the database appears to still restore successfully, but there is no auto logout and prompt to login again.

Concerned though that it might not have restored everything properly?

If it said “already in use” restore not completed.

Drop that database (the one that have the same name) and restore again.

How is the best way to do that for LocalDB? Since I am using 2 systems (client’s POS and my laptop), databases are named same. When I restore to another machine (my PC in office), I don’t get this error coming up and is same SambaPOS 5 configuration.

In LocalDB, as I am using default instance and also the default SambaPOS5 database name, if I drop it using management studio, then SambaPOS won’t open, or it will recreate a sample DB on startup.

So is the only option to restore using management studio in this case? I prefer to just use database backup feature as it’s much faster :wink:

So it says database in use. I don’t know why database is in use but it makes sense to stop restoration in this case. If it is an issue caused by SambaPOS and if it can be reproducible I’ll be glad to fix that.

I expect it to regenerate sample db…

I think it might be an issue on my laptop, as it’s running quite slow these days, possibly it hasn’t closed connection to database fast enough before it tries to overwrite it.

I’ll just try deleting database, let it create sample db then restore to that. If failing that, I’ll just do it on management studio. I’m not using this laptop every day anyway so it’s not a huge concern for me.

Seeing whole error message might give a better idea…

From your topic title I guess… LocalDB directly creates mdf files under c:\Users[user name]\ folder. If you try to restore a database and if there is another database with that name… that may create an issue.

Error message was identical to the one in the linked topic (that was for V4) so I didn’t mention it again. It was just a one line windows dialog.

Yeah anyway I think it isn’t any issue with SambaPOS, if I experience it on other systems I’ll let you know.

1 Like

OK. When it happens also check your C:\Users[User Name] folder and let me know mdf files located there.

I know in c:\Users[user name]\ folder the filenames will be same as those from the one I am restoring from, just default names of SambaPOS5.mdf and SambaPOS5_log.ldf. Because I had the option ticked to allow overwrite it usually works. Actually I should be naming them differently but I only recently started using LocalDB on single terminal setups, before was using CE for that, or SQL Express. Just being lazy not to change the connection string :stuck_out_tongue:

It should work without renaming but as it says “already in use” there is something unexpected there. It shouldn’t say it for actually used database as we handle it during restoration. This is what I mean…

Assume you have both SambaPOS5 and SambaPOS4 mdf files in that folder. You received SambaPOS4.bak and want to restore it to SambaPOS5 and enabled overwrite… However as you also have SambaPOS4.mdf as a separate database, restoration should break as it should overwrite SambaPOS4 (not actually used one) database. We shouldn’t change SambaPOS4 database while you try to restore it on SambaPOS5.

No I am not upgrading. I am just using SambaPOS5. I was restoring a backup database from client’s POS terminal to my laptop, but both would be using SambaPOS5.mdf. Like you say it’s unexpected so I don’t think we need to worry about it right now.

Haha I know you’re not upgrading just wanted to give an example we’re familiar with. At least if it is the case I know you’ll quickly remember this :wink:

1 Like

Actually I turned off this feature:

Then it restored successfully. Bit unexpected.

Both current database and database in backup was using same filename of SambaPOS5.mdf.

1 Like

unchecking this setting worked for me too on 5.1.57.