0

So I have made a set up file and install it to target computer which has no .Net 4.0 or SQL Server 2008.

I add them as prerequisites and setup downloaded from the internet the .Net 4.0 and SQL Server 2008. The setup finished successfully.

When I run the program, it gives an exception:

cannot open xxxxxx.mdf file. it is version 650. and your is xxx...

I searched it out and learned that SQL Server installed on target computer is lower than the database file I created (the database file was created in SQL Server 2008 R2).

So, no connections can be opened.

To solve this, What can I do?

Thank you...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
unnamed
  • 840
  • 9
  • 26
  • 38
  • Add as prerequisite SQLServer 2008 R2, or distribute a script that recreate the database in the version required. – Steve Jun 21 '12 at 17:37
  • @Steve There is no option for adding sqlserver 2008 r2. Can you explain script distributing? How it is done? – unnamed Jun 21 '12 at 17:48
  • Have you solved this problem? If you don't mind i will suggest to look at [LocalDB](http://stackoverflow.com/questions/9655362/localdb-deployment-on-client-pc) as alternative to full SQLServer installation – Steve Jun 24 '12 at 12:40

2 Answers2

2

You can't attach a 2008 R2 database to a 2008 instance - you can only go forward, not backward. So either install 2008 R2 at the destination, or you'll have to re-create your database in 2008. If you install 2008 locally alongside 2008 R2, you can create an empty database in 2008 and use tools like Red-Gate's SQL Compare / SQL Data Compare, or the schema compare feature in SQL Server Data Tools, to translate your database relatively quickly.

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
0

There is no way to open an MDF file with a lower version of SQLServer.
Of course you could add as a prerequisite SQLServer 2008 R2 (express or full).
But the best course is to distribute a SQL Script containing schema and data.

This could be done using SqlServer Management Studio,

  • Right click on the database
  • Select Task
  • Select Generate Script.
  • Follow the Wizard.

In the last page of the wizard you could find the button Advanced
Clicking on it will give you full control on what to put inside the script.
The script could be distributed with your application with instructions on how to execute on the target machine.

Steve
  • 213,761
  • 22
  • 232
  • 286
  • A script containing schema and data could reveal IP that wouldn't be necessary when attaching a database. For example, if stored procedures are "encrypted" - even though this is not really encryption, it does protect your IP from the casual curious person. – Aaron Bertrand Jun 21 '12 at 17:42
  • @AaronBertrand, yes, but it seems the only viable solution apart from installing on the dev machine a lower version of SqlServer or the correct version on the customer machine. All in all, seeing the OP has already included as prerequisite the install of SQLServer, he could also be more specific on the version required. – Steve Jun 21 '12 at 17:46
  • There is no option for adding sqlserver 2008 r2. How do you do that? – unnamed Jun 21 '12 at 17:49
  • @Un_NatMenDim How did you explicitly make 2008, specifically, a prerequisite? Anyway if you're going to allow users with 2008 to install your program, you need your database to be compatible with 2008. This means it can't be created in 2008 R2. – Aaron Bertrand Jun 21 '12 at 18:02
  • @AaronBertrand right clicking my Setup project in VS2010 and select properties, then clicking prerequisities. there we have Sql Server 2008 prerequisities, but not r2.. – unnamed Jun 21 '12 at 18:21
  • Well I guess the question is - do you want 2008 R2 to be a prerequisite? You might be excluding users who have 2008 installed. It is probably better to make your database compatible with 2008. As for why the option isn't there, I don't know. Have you installed VS 2010 SP1 and any other updates? – Aaron Bertrand Jun 21 '12 at 18:22
  • @AaronBertrand There is no option, cause Microsoft does'ny care about it. My user have no idea what a database is. I just want them to use the program that I made. – unnamed Jun 22 '12 at 07:10
  • So create your database in 2008. This has nothing to do with Microsoft not caring. This has *always* worked this way - you can't attach a 2005 database to 2000, a 2008 database to 2005, etc. I think your anger is misplaced. – Aaron Bertrand Jun 22 '12 at 11:25
  • @AaronBertrand I'm not angry. just don't understand why Microsoft does'nt make a bootstrapper for r2. that's it.. – unnamed Jun 22 '12 at 11:43