November 0908

The database cannot be opened because it is version 655

I recently upgraded to Windows 7, which I really like, and decided that I’d not bother installing SQL Express 2005 as 2008 is out and can be installed from the Web Platform Installer. Just last night I needed to do some work on a WinForms project I’ve been building – I started it with a 2005 Express database but figured it couldn’t hurt to use 2008 as it should handle older versions. Wrong! When I tried to start debugging it threw the following error:

The database 'C:\Users\Simon\Documents\Visual Studio 2008\Projects\OTJewellery\src\app\OTJ.Program\OTJDB.mdf' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported.

Could not open new database 'C:\Users\Simon\Documents\Visual Studio 2008\Projects\OTJewellery\src\app\OTJ.Program\OTJDB.mdf'. CREATE DATABASE is aborted.

An attempt to attach an auto-named database for file C:\Users\Simon\Documents\Visual Studio 2008\Projects\OTJewellery\src\app\OTJ.Program\OTJDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

This confused me, a lot. I’d started this database using an older version of SQL Express but the error was saying that version 655 wasn’t supported because SQL Express 2008 could only deal with versions 612 and earlier.

After a bit of searching I discovered that Visual Studio 2008 SP1 would allow me to connect to a 2008 database from Visual Studio, but when I tried to debug the application I still got the error above, this made me wonder if the post had got it right – their situation seemed similar to mine but why couldn’t I connect to the database. It was getting late and I needed to stop but thought I’d give one last thing a try. I removed the connection to the database from the Data Connections in Server Explorer and tried to add it again. To my surprise it connected.

Looking at the properties of the connection the difference was clear, this is my original connection

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\OTJDB.mdf;Integrated Security=True;User Instance=True

and this the new one

Data Source=.;AttachDbFilename=|DataDirectory|\OTJDB.mdf;Integrated Security=True;User Instance=True

Seems like the new version doesn’t need to declare the SQL Instance it is connecting to, at least if it is the default instance. I wouldn’t have done things this way, personally I’d prefer to see the instance explicitly named but maybe it makes sense.

Unable to open the physical file – Operating system error 32!

I woke up this morning thinking I’d post about the problems I’d had last night then add a simple feature to the app I’m working on. I didn’t think it would take too long to implement a read-only view but on starting to debug the app ran into my next problem:

Unable to open the physical file \"C:\\OTJ\\DBFile\\OTJDB.mdf\". Operating system error 32: \"32(error not found)\".

An attempt to attach an auto-named database for file C:\\OTJ\\DBFile\\OTJDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

The path is different to the original error because this is where I’m actually running the app from, it is the install path I’m using to check it works.

When the app is started it first checks the database exists, if it can’t find the database then it copies a new version to the install path. If the database exists it checks that it is up to date by comparing a value in a config table with the version number and then runs any associated update scripts. When I remove the database and start debugging a new copy of the database is placed in the path identified in the error, so I know it can’t be tripping over itself by finding a previous version. Also it seems to read some values from the database but not others. I’m finding this very confusing.

I haven’t got an answer to this yet, but when I do will post a follow up. In the meantime if anyone knows how to fix this please let me know in the comments.

Permalink | Comments (1)

Comments

  1. watch south park United States watch south park (Thursday, December 03, 2009) #

    Nice post I Like your site very well and continue to do so. I have bookmarked your site.

    Regards
    Vickers


Comments are closed