SQL 2005 express with 2008 express compatibility - sql-server-2005

I installed VS 2008 without SQL 2005, then I installed SQL 2008, then I needed 2005 express so I reinstalled VS checking the SQL feature.
The installation went OK, however I still cannot open mdf files from VS.
I think there is no 2005v instance installed.
When I dbl-click an mdf file in VS I get the following message:
Connections to SQL Server Files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http:go.microsoft.com/fwlink/?linkID=49251.
Update
I tried to attatch it, it doesn't work.
When I tried to attach it to SQL 2008 it doesn't work, when I try to attach it to SQL inside VS, I get the following error message:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I suspect that SQL 2005 doesn't have any instance at all.
I opened SS manager and I didn't see any installed instances.
I don't know how to install an instance, or else if there is a way to open with 2008 tell me.
Any help will be really appreciated!

You don't just "open" an mdf file in Visual Studio - you need to "attach" the file to your SQL Server instance, then access it by creating a SQLConnection (System.Data.SQLConnection) from your VS application. See here for more info on attaching databases (note the FOR ATTACH option), and here's a good intro on accessing SQL Server data using a SQLConnection.
Oh, and if you should happen to see anything about "user instances", pretend you didn't. It was supposed to make auto-attaching databases easy (in fact, attaching databases isn't all that hard anyway). Microsoft is warning that the feature will be discontinued in later releases of SQL Server, so you're better off just learning the "right" way to do it.

Related

Downgrade from SQL Server 2014 Express to SQL Server 2012 Express

I had SQL Server 2012 Express installed on my PC at work, but we received a file from a client the was created in SQL Server 2014. Please keep in mind, I am newbie, and I only made this mistake about 7 months ago
I tried to install SQL Server 2014 Express as another instance on my PC along with SQL Server 2012. After noticing that my new SQL Server instance did not work and my old SQL Server did not work, I looked online and found that what I did was a step up from what an ape would do. Always read before attempting an install.
After un-installing SQL Server 2014 I tried to relaunch SQL Server 2012, but it would not connect to my instance that I was able to just before.
I now get this error:
Cannot connect to STID02\SQLEXPRESS.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)
I have also read this thread Can't connect to SQL Server 2014 Express and found that the SQL Server service is stopped and I cannot start it, and the SQL Server Agent Service is stopped and won't start either.
I have not been effected by this until recently, I need to do some testing with DB's but I need my local instance to do the testing. I would appreciate any advice, as I am still new to SQL Server and most computer related things I would be very thankful to those how can dumb it down extremely low.
Thank you -Anthony
In short, uninstall everything, then reinstall the version you want to use.
Some configuration files must have been overwritten by SQL Server 2014. Don't worry, it can be fixed.
First: do you need any of your existing databases? I assume not as you haven't been using SQL Server for the last 7 months. If you do need some of the databases you'll find the .mdf, .ldf files in you SQL Server installation folder somewhere in the DATA folder.
Then: Uninstall SQL Server 2012 - note that since you've corrupted your current installation it might happen that some registry entries will be bad and/or services or libraries won't be removed. In that case fix the registry entries using some tool, like CCleaner, and try again to remove those programs/services.
Last step: reinstall whichever version you want. If you needed your previous databases overwriting the new mdf/ldf files should do the trick (of course while the server is not running). You can check the server's state from the SQL Server Configuration Manager or from Services.

SQL Server 2012 Express, Connection error 26, Local connection

I am working locally on new laptop (windows 8 x64) with SQL Express 2012 SP1 x64, and I get the following connection error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Kindly notice that service sqlserver is running and that shared memory, TCP/IP, Named Pipes are all enabled.
Sometimes connection is successful but only for a while.
Usually I get the connection error.
Any ideas how to resolve this issue?
Thanks in advance
Check in Windows Services, sometimes the instance of SQL Server is stopped after some updates either in Visual Studio or SQL Server. I think you mean, sometimes IT IS NOT connecting, but after some seconds it does work. Am I correct?
I've renamed my computer, sql Express was looking for the database server on the wrong path. Renaming computer back or updating path would fix that.
That might not be your issue, but help someone else.
Instead of SQL Express - can you connect to and use - (localdb)/v11.0 ?
localdb is lighter weight comparing to sqlexpress and it is the recommended way for developers to put some data quickly in SQL. Also note that localdb does NOT run as a service but as an app, so it might be easier to connect to it. Here is a question discussing other differences.

SQL Server 2008, Error: 948 While Attach Database got Version error?

Yesterday I installed SQL Server 2008 on my laptop (Windows 7 64 bit), I need to attach a .mdf to the server, but when I try to do this, I get this error:
Attach Database failed for server 'prince/sqlexpress' (Microsoft.SqlServer.smo)
ADDITIONAL INFORMATION:
1.An Exception Occured while executing a Transact Sql statement or Batch (Microsoft.SqlServer.connectioninfo)
2.Unable to open the Physical file Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)
With the help of Internet, I found some solution.
1.Start SQL Server manager as Administrator (right-click on the program, choose "Start as administrator"):
But I still got the same error.
That .mdf file does have have permission, so I moved into external drive (pendrive because my system have only C:\ drive, yet no partition I have done ) .
Then I got another error,
Attach database failed for Server 'Prince\SQLEXPRESS'.
(Microsoft.SqlServer.Smo) ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
The database 'Databasename' cannot be opened because it is version
655. This server supports version 611 and earlier. A downgrade path is not supported. Could not open new database 'Databasename'. CREATE
DATABASE is aborted. (Microsoft SQL Server, Error: 948)
I use the Query -
"select ##version;"
I got the Output as
"Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86) Feb 9 2007
22:47:07 Copyright (c) 1988-2005 Microsoft Corporation Express Edition
on Windows NT 6.1 (Build 7600: )"
what shall i do? But i installed SQL Server 2008. how do i change that?
How to solve this error, please help out this problem, If you have any solution please post it.
The message is very clear: the database MDF file is version 655. Your server understands version 611. Which means, despite to your claim to the contrary, that you are connected to a SQL Server 2005. Install a SQL Server 2008, connect to it, and attach your database. Please pay attention during the installation process to the instance name you choose and make sure you connect to that instance. You can also check now what instances you have installed, look at what services you have on your system. MSSQLSERVER will be the default instance, MSSQL$<instancename> will be a named instance. Use any SCM query tool to see what services you have installed, eg. sc.exe.
Microsoft SQL Server Management Studio needs Administrator rights to attach database in Windows 7. If you execute it directly so you will get the error 5120. Fix this executing Management Studio icon using the right mouse button and selecting execute as administrator. Good luck.
Finally I Solved My Problem,
Stop the SQLEXPRESS service and Uninstall all the Components related to SQL server 2005.
Then Open the registry Editor Go to HKEY_LOCAL_MACHINE--SOFTWARE--MICROSOFT--MICROSOFT SQL SERVER-DELETE the folder 90. Then again reinstall SQL Server 2008 and create new instanse for 2008 server. Now its working, I m able to Attach the mdf file.

Connecting to SQL Server 2008 Express from VB 2008 Express

I'm using VB 2008 Express for our College Project. I'm also running SQL Server 2008 Express and have installed SQL Server Management Studio and used it to create my database.
Both software have been installed and running locally. I'm trying to connect to the database from VB 2008 Express. Database connection wizard have 3 options:
connecting to Access db
connecting to SQL Server 3.5 compact db and
connecting to SQL Server db file.
There are no problems connecting to the first two but when I try to connect to my SQL server DB file (.mdf) it throws the following error ("Unable to open the physical file .... Operating system error 32:(failed to retrieve text for this error. reason:1815.......an attempt to attach an auto-named database for file ...... .mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share")
I appreciate if anyone who had the same experience and overcome the problem could point me in the right direction.
Thanks very much.
Little Critter.
You need to detach your database from the server. Since you created the file there it is already running on the SQL Express server. Operating System Error 32 is a sharing violation and it means that the file is in use.
Try this:
Open Sql Express 2008 Managment Studio and find your database in the Object Explorer tree.
Right click on your database, choose tasks, and then select "Detach"
When the "Detach Database" dialog appears, select the checkbox that says "Drop Connections"
Click ok.
Your database should detach from the database server. Now the server will no longer bring that database up automatically and you should be able to get exclusive access to it.
Note that if you want to make more edits to the MDF you will have to reattach the database or you will need to use the tools built into VB 2008 Express. Because of this most people would choose to leave the database attached and not run it as a "User Instance". Check out this link for alternative ways to get to your data: How to: Access and Initialize Server Explorer/Database Explorer.
Anyway, you may have your reasons for setting it up this way. The steps outlined above should fix you up. Good luck with your project!

Problem connecting VWD Express 2008 to SQL Server Express 2005

WHen i try to connect to SQL Express 2005 from Visual Web Developer Express 2008, i was getting errors like 'Could not load file or assembly Microsoft.SqlServer.Management.Sdk.Sfc' .
I read some posts which advised me to download and install 3 applications to address above issue ( SharedManagementObjects.msi, sqlncli.msi,SQLSysClrTypes.msi ).
I did that and now i get a different connection error
'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) '.
Does anyone know a way of overcoming this ?
Thanks.
How are you trying to connect ? Just a regular ADO.NET connection? If so, what's your connection string?
Are you trying to use SMO (SQL Mgmt Objects)? This sounds like some of your SMO objects aren't available for some reason - you might want to download and reinstall those SMO components from here. The files you want are quite a bit down the page, under the heading of "Microsoft SQL Server 2005 Management Objects Collection" - files are called "SQLServer2005_XMO.msi" (with some x64 variations).
Does installing that MSI help at all?
Marc
PS: okay, thanks, based on your comment - can you try this connection string here:
string connectionString = #"Server=.\SQLEXPRESS2005;Database=DBName;Integrated Security=SSPI";
If you are running SQL Sever Express locally another thing you may want to do check in the Services console (WinKey, Run, 'services.msc') and verify that you have SQL Server and SQL Server Agent entries and that they are both running.
I think this problem is certainly with your connection string. Try doing this
Run the SQL Management Express, and get the server instance name from it.
Usually this problem occurs when the server instance name is wrong (on many computers it could be SQLEXPRESS).