I always get this error. what should i do? - c#

The database 'C:\USERS\ROANEPC\DESKTOP\FINAL\BROADCASTWEB\APP_DATA\ASPNETDB.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'C:\USERS\ROANEPC\DESKTOP\FINAL\BROADCASTWEB\APP_DATA\ASPNETDB.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Users\RoanePC\Desktop\Final\BroadcastWeb\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Database version:
655 means SQL Server 2008 instance.
661 means SQL Server 2008 R2 instance.
684 means SQL Server 2012 CTP1 instance.
706 means SQL Server 2012 instance.
782 means SQL Server 2014 instance.
You'll need to install the R2 version and continue to use that version. Downgrades do not work as in your example from 2008 R2 (10.50) to 2008 (10.00) but you can upgrade versions.

Related

Understand localDB is relation to SQL Server Express and SQL Server CE

I'm trying to understanding LocalDB by reading MSDN: SQL Server 2016 Express LocalDB and MSDN: SQL Server Express LocalDB and SQL Server Express and a number of SO posts including confusion about SQL Server Express and localdb, I still cannot understand what is LocalDB. I understand and have used SQL Server Express and SQL Server CE.
Questions:
LocalDB...the necessary SQL Server infrastructure is automatically
created and started
My understanding is that, if using LocalDB to handle an application's database, neither the developer nor the client machine where the application is deployed needs to install the heavy SQL Server Express, but just need to install the lighter LocalDB. How, then, without SQL Server Express install can localDB "create(d) and start(ed)" SQL Server? If localDB
... once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the users' local AppData path which is normally hidden.
If developer or client can use localDB without installing SQL Server, how can localDB be an instance of something that is not installed? Or is localDB an incomplete version of SQL Server Express that just does not need to click..click..click.. to configure. Essentially localDB works like SQL Server CE where localDB use some hidden "files" in AppData to create database while SQL Server CE use the dll to generate the database?
SqlLocalDB.msi program to install the necessary files on the computer
If client still needs to install localDB (which is not really portable along with the application like SQL Server CE), then why not just install SQL Server Express? Either localDB or SQL Server Express is above 100MB+ anyway and need separate installation, what is the point of using localDB anyway?
LocalDB is a programmer-oriented version of SQL Server Express that needs to be installed just like SQL Server Express.
Unlike SQL Server Express, it's not installed as a Windows Service that starts up with your Windows OS - but it only starts up as needed (when your application starts up, or when you start it manually with the SqlLocalDb command line tool).
But LocalDB IS SQL Server Express (not Compact Edition). It uses the same .mdf and .ldf database files like and desktop/server version of SQL Server, not SQL Server CE's .sdf file format.
We used localdb on a project where we had agents in the field using laptops.
The functionality of localdb was better than SQL Server CE (I don't remember exactly what CE was missing, but it was important to the project), you should review the functional differences.
Another advantage was the db was stored in the user folder which makes it impossible for other non-admin users of the laptop to see. This allowed us to reuse and even share laptops between users without mixing data - a nice feature.
Finally, the dbs (with a little effort) can be copied to the dev/support side and restored/attached for troubleshooting. They are full .mdf/.ldf database files.
You do have to create the instances using a command line (sqllocaldb utility), after the product is installed. This was just part of our install app.

Set SQL Server 2008 R2 as a prerequisites while making a C# set up file

I have developed a C# desktop application. I need to deploy it in a client's machine. This app needs SQL Server 2008 R2. It is not feasible to set up SQL Server first and then my app. So, I thought of giving dependencies. Unfortunately the prerequisites option in VS has no option to include SQL Server 2008 R2.
It has only option for SQL Server 2005 Express and SQL Server 2008 Express.
How do I include SQL Server 2008 R2?
Sql Server 2005 express and Sql Server 2008 express come with below Limitation :
uses only 1 CPU
can use max of 1 GB of RAM
is limited to 10 GB of database size
you can use these software for individual system (desktop).
But Sql Server 2008 R2 is dedicated database server ,you can install it same system or separate system.
you need to write custom code for pre-detection Sql Server 2008 R2 Instance.
Below link would be helpful :
https://msdn.microsoft.com/en-us/library/a6t1z9x2.aspx
http://www.codeproject.com/Articles/16231/Deploy-your-Application-and-Database

Error 948 :Visual Studio 2012 with SQL Server 2008 R2

I have a computer that working as server and client machine. I installed SQL Server 2008 R2 and Visual Studio 2012 in it.
Using SQL server management studio I generated a DB then I created few table in that DB , then I insert data into it.
Then I deattached that DB using Server Management studio . Then I move that DB into my project "App_Data" folder.Then using "server explorer" & T_SQL pane functions of Visual Studio 2012 I did few changes of that DB .
Since I want to do massive changes , I close that DB connection with the project. I move that DB into SQL server default Database Location which is
"C:\Program Files\Microsoft SQL
Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA"
then I try to attach that DB using server management studio , I'm getting
"Error 948"
Cannot be opened because it is version 706. This server supports
version 661 and earlier
How to overcome this error ? your ideas/suggestions highly appreciate
By default, you can't attach a DB file from a SQL Server 2012 to an instance which is running SQL Server 2008 R2.
Version 661 is a SQL Server 2008 R2 DB file and version 706 is a SQL Server 2012 DB file. More information: How to determine version of Local Sql Instance and your database
You will therefore need to update your SQL Server instance, e.g. by upgrading to SQL Server 2012
I would also recommend you patch to the newest released build of SQL Server 2012. Check here for the newest version numbers for the different SQL Server versions: Microsoft SQL Server Version List
its a version comparability issue.
Initially you created in sqlserver 2008 R2 that version would be 661 and when you moved to VS2012 it was updated to 706, and when you tried to go back to SQl server 2008 R2 again this 706 version is not being downgraded to 661, obviously it can't be done.
one simple solution without any changes to your server setup, use Generate Script feature that should help you.

How to open the mdf file

Please help me about this.. I use to attach a database but it has an error this is the error. And I use SQL Server 2012
Microsoft SQL Server Management Studio
Attach database failed for Server 'DANICA-PC\SQLEXPRESS'.(Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The database 'MTS' cannot be opened because it is version 782. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'MTS'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)
You cannot do this - you cannot attach/detach or backup/restore a database from a newer version of SQL Server (the mdf file is version 782 - this is SQL Server 2014) down to an older version (version 655 is SQL Server 2008) - the internal file structures are just too different to support backwards compatibility.
You can either get around this problem by
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.
I would try scripting out the tables and data and then creating it in SQL Server 2012 so you'll have a compatible version. You are trying to attach a SQL Server 2014 database with SQL Server 2012. The database is incompatible with your SQL Server.

Cant connect to Database. Visual Studio 2013 aspx [duplicate]

This question already has answers here:
The database cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported
(4 answers)
Closed 9 years ago.
I have Visual Studio 2013, and SQL Server 2008 and 2012. They both support my computer. My database was created in VS2012 and i cant open it in VS2013. I installed all the tools that there is in VS2012. I tried to have a connection string in the Web.config. Everytime Im trying to send some data to my database, i get this message:
The database 'C:\USERS\XXXX\DESKTOP\XXXXX\APP_DATA\DATABASE.MDF'
cannot be opened because it is version 706. This server supports
version 662 and earlier. A downgrade path is not supported. Could not
open new database
'C:\USERS\XXXX\DESKTOP\XXXXX\APP_DATA\DATABASE.MDF'. CREATE DATABASE
is aborted. An attempt to attach an auto-named database for file
C:\Users\XXXX\Desktop\XXXXX\app_data\DataBase.mdf failed. A database
with the same name exists, or specified file cannot be opened, or it
is located on UNC share.
http://i.imgur.com/ioXgagk.png
What can I do next?
Thanks.
You can't open a database created for Sql Server 2012 with Sql Server 2008. To make this work, you need to open the database in Sql Server 2012 and change the compatability level from 110 (Sql Server 2012) to 100 (Sql Server 2008 and Sql Server 2008 R2). Hopefully you haven't used any features of Sql Server 2012 that will prevent this change.

Categories