asp.net SQL server error - asp.net

I am getting following error when I run my website on my laptop which i created on another computer
The database 'C:\DOCUMENTS AND
SETTINGS\ASIF\DESKTOP\APP\WEBSITE\APP_DATA\DB.MDF'
cannot be opened because it is version
661. This server supports version 612 and earlier. A downgrade path is not
supported. Could not open new database
'C:\DOCUMENTS AND
SETTINGS\ASIF\DESKTOP\APP\WEBSITE\APP_DATA\DB.MDF'.
CREATE DATABASE is aborted. An attempt
to attach an auto-named database for
file C:\Documents and
Settings\asif\Desktop\App\Website\App_Data\DB.mdf
failed. A database with the same name
exists, or specified file cannot be
opened, or it is located on UNC share.
Please suggest me solution to this.
Regards,
Asif Hameed

Version 661 is SQL Server 2008 R2. You are trying to attach a database created with this version to an earlier version of the engine, which is not allowed.

Are you trying to use a SQL Server 2008 R2 database in SQL Server 2005? They are not backwards compatible.
See http://forums.asp.net/p/1560835/3859344.aspx and http://social.msdn.microsoft.com/Forums/en/sqlexpress/thread/2744a003-d61c-4d3d-93c2-af946e141e7e.
Edit
Also, if you have multiple SQL Server engines installed, make sure connection is pointing to the correct one. It might be an instance name like computername\instance instead of just computername.

Related

Could not load file or assembly microsoft.sqlserver.management.sdk.sfc

Receiving below error message in Visual Studio 2008 while creating a connection for database.
could not load file or assembly
'microsoft.sqlserver.management.sdk.sfc ,Version=10.0.0.0,
Culture=neutral,PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified.
I am trying to create database internally i.e. .mdf file and store it in the App_data folder.
But I'm not able to create the connection.
Please help me to sort out the issue quickly.
You can download these files from Microsoft website.
1.Microsoft SQL Server System CLR Types
2.Microsoft SQL Server 2008 Management Objects
3.Microsoft SQL Server 2008 Native Client.
After installing the above three files try to connect your application with sql server database and if still you got the same error message then don't worry and close your application then start it again and you will be able to connect it.

Establishing connection to SQL Server Error

I opened my web project today and for some reason I could not gain access to my database files. I get the following exception whenever I try to add, edit or refresh my database:
A network related instance specific error occurred while establishing
a connection to SQL Server. The Server was not found or is was not
accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections.
I took a look at my connection string for any spelling errors and deleted my database and replaced it in the folder I had it in. I can't seem to find a fix for this so any help would be a appreciated. I am using Visual studio 2008 for this web project.
This sounds like the same problem that I had myself awhile back. My problem was that my SQL service pack 1 did not install properly so I had to install Microsoft SQL Server System CLR Types, Microsoft SQL Server 2008 Management Objects and Microsoft SQL Server 2008 Native Client. After that I could create new SQLdatasources but I could not edit the ones I had previously before my problem. I had to restart my computer in safe mode and delete my SQLEXPRESS folder then recreate the database connection in visual studios. When I finished that everything worked fine.
This is the site I got those downloads, http://blogs.cametoofar.com/post/cannot-load-file-or-assembly-microsoftsqlservermanagementsdksfc.aspx

cant connect to database and choose a database

I installed adventure works, and I followed the instructions on this page:
How to: Create Connections to SQL Server Databases
basically nothing appears in the drop down, in step 2.
I cant even attach the database without getting an error, nor drag it to the web form.
It tells me that the database cant be attached cause it is version 705, and the server supports version 655..
Also what is teh difference between attaching the database and connecting to it?
I went to the installation center of 2008, and clicked on show installation info..I got this:
Microsoft SQL Server 2008 Setup Discovery Report
Product Instance Instance ID Feature Language Edition Version Clustered
Sql Server 2008 SQLEXPRESS MSSQL10.SQLEXPRESS Database Engine Services
1033 Express Edition 10.1.2531.0 No Sql Server
2008 SQLEXPRESS MSSQL10.SQLEXPRESS SQL Server Replication 1033 Express
Edition 10.1.2531.0 No
so I guess it is installed on my computer, but I cant access the application
You need the database to exist in an instance of SQL Server (or whatever RDBMS you so choose...but most likely, SQL Server). To do this you can do a few things: namely restore a *.bak database backup file of AdventureWorks, or you can attached the mdf and ldf files (database data and log files) to get your database online.
basically nothing appears in the drop down
Do you have an instance of SQL Server installed on your machine?
Also what is teh difference between attaching the database and connecting to it?
Attaching the database is using mdf and ldf files to get your database online ready for transactions. Connecting to the database is creating a connection between a client application and the aforementioned database. Two very different steps of the data access process.
Attaching to a database is necessary when the database file(s) are in a location other than the default location. You don't really "connect" to a specific database per se. You connect to a sql server instance which contains a list of databases on that instance (or referenced by the instance).

SqlExpress mdf DB incompatibility

I used the ASP.NET (.NET4) default ASPNETDB.mdf database that gets created when using membership, in one of my sites. I then copied the site to the web server. Now it has been running for a while so there is content and comments. But I now need to make changes to the code that will also require extra fields in the db, so I copied the .mdf from the server to my local machine to edit and add the fields(so I didnt lose content etc). But when I run the project after replacing the mdf i get the following error:
"The database
".....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. Cannot open user default
database. Login failed. Login failed
for user 'Me-PC\Me'.
This confuses me, as it is the exact mdf file that my home VS generated. The server is running the same .NET as I am too, so I dont see why it would have changed anything.
Thanks!
Ok, so it turns out the server was running a different version of MSSql Server 2008 R2 (yeah?) which meant that the db file was getting upgraded, so when it came back to my lowly system it failed. Had to uninstall and reinstall both VS 2008 and SQL Server 2008

SQL server won't open DB created by Visual Studio

I've built an ASP.Net site in Visual Studio, and created the DB inside it (the .mdf file is in the APP_data folder).
Now, when I want to deploy in the customer site, I think about maintaining the DB without open Visual Studio, and by using the SQL Server Express tools (back up etc.).
I've searched how to do this, and learned that I should attach the .mdf file to sql server.
I've tried to do this and failed!
The error is: Unable to open the physical file "< .mdf >". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)
Google didn't helped me to solve the problem.
Now I have 2 options:
1. To give up and deploy the site in the current situation where the DB is an .mdf file and ASP.Net can connect to it by the SQL server express compact (in the proccess).
To extract all the data (I need to think how...) and import it to new DB, this time in SQL Server DB.
Wat would you recommend doing?
Thank you in advance.
If on Windows Vista or higher, try opening SQL Server Management Studio by right clicking and saying "Run as Administrator". As Mitch mentioned maybe it is just a permissions issue. Then try attaching to the database.
Error 5 is usually permissions related. Do you have permissions to access the file in it's location?
If you've created it in Visual Studio, it's most likely an Express database. SQL Server does not support "user mode" database connections which SQL Server Express use. Despite sharing a name, they are two fairly distinctive and different technologies.
To view the contents of an SQL Express database (ie- created in Visual Studio) I just use the Visual Studio server explorer.

Resources