0

As a beginner in C#/VS I want to practice making basic LINQ queries on simple DB's. I downloaded the "famous" Northwind and Pubs databases on the official Microsoft websites (https://www.microsoft.com/en-us/download/details.aspx?id=23654). It gave me a .msi files that installed 6 files on my c: instnwnd.sql, instpubs.sql, NORTHWND.LDF, NORTHWND.MDF, PUBS.MDF, PUBS_LOG.LDF.

When I launch Visual Community 2015 and simply make an "Open => File..." and open the "instnwnd.sql", it opens the .sql file without problem. The problem is when I'm trying to make a connection to the database, being either through the Solution Explorer (Data Connections => Add Connection) or while I'm trying to create an EDM (Database first), which is what I want to do eventually.

The exact problem is that one : the Northwind and Pubs databases doesn't show up in the database list when i'm trying to add a connection, I only get the system databases. Here is what I get :

http://img15.hostingpics.net/pics/128870screenshot1.jpg

I read many MSDN documentation pages and several StackOverFlow topic about the matter (the closest of solving my issue was that one, but didn't work :How to connect to LocalDB in Visual Studio Server Explorer?). I have SQL Server Express 2014 with tools, started SQL services in my Windows Services etc.

What should I do in order to have those databases available so I can generate code and starting making my LINQ exercices ?

Thanks in advance !

Community
  • 1
  • 1
Morgoth
  • 237
  • 2
  • 11
  • 1
    Have you "attached" the databases to your SQL instance? If you connect using the Microsoft Sql Server Management tools do the databases appear? My guess is either the databases are not attached, or there is a security issue... But with a lack of permissions you can usually see the databases, just not access them. – Yort Nov 25 '15 at 18:39
  • Thanks for your answer. Here is what I get : - When I open the databse in SQL server 2014, just like in VS, no problem - When I try to Attach the database, I can run the script (top of the window) with no problem, but when I click OK (which is supposed to attach and create the database I presume, I get this :" An error occurred when attaching the database(s). Click the hyperlink in the Message column for details. " The error message in the "Messages" is : (see next comment) – Morgoth Nov 25 '15 at 19:30
  • Msg 1813, Level 16, State 2, Line 3 Could not open new database 'Northwind'. CREATE DATABASE is aborted. Msg 950, Level 20, State 1, Line 3 Database 'Northwind' cannot be upgraded because its non-release version (539) is not supported by this version of SQL Server. You cannot open a database that is incompatible with this version of sqlservr.exe. You must re-create the database." So I guess my Windows/SQL/Visual Studio are too recent... – Morgoth Nov 25 '15 at 19:30
  • i'd rater say it's you'r sample that is out of date – Antoine Pelletier Nov 25 '15 at 19:48
  • yeah that's more accurate and logical :) The problem is there is no updated version of these. Could any of you guys direct me towards a small recent sample database to practice my basic LINQ query ? Thanks all for your answers. – Morgoth Nov 25 '15 at 19:53
  • That's odd. In every case where I've done something like this, attaching an older database to a newer sql instance has automatically upgraded the databases to the new format. It's only a problem going back the other way (newer databases on an older sql server version won't work). The message about a non-release version is not something I've seen before though. – Yort Nov 25 '15 at 20:44
  • I've just tried the same methods with a 2014 version of the AdventureWorks database, and it went just fine, both in SQL Server 2014 and VS 2015. Thanks again everyone for your answers. – Morgoth Nov 25 '15 at 20:51

1 Answers1

0

You need to attach the databases before you can see them**. You're having a problem attaching the databases due to versioning (which is odd), but your sample db's are very old. Perhaps try newer ones from here https://northwinddatabase.codeplex.com/ and make sure you attach them before expecting them to show up in the tools.

** Technically this is not true. I believe there is a way of connecting to sql server and passing a file path in the connection string, however this will likely still fail for your due to the error you get trying to attach the dbs you have. Additionally, it requires a specially crafted connection string which may or may not be usable with the gui tools you're trying to use. It is also, in my opinion, a less common way of accessing sql server databases, so I would stick with attaching them first. If you want to find out more about this, I believe the feature you need to research is called 'sql server user instances'.

Yort
  • 787
  • 8
  • 22
  • There's also this set of sample databases, which might be useful. You could try adventureworks (ad) instead of northwind - I think adventureworks is a more modern sample. http://www.microsoft.com/en-us/download/details.aspx?id=41700 – Yort Nov 25 '15 at 20:52
  • SQL 2000 databases are just too old to be supported. See this; https://weblogs.asp.net/dixin/attach-sql-server-2000-database-to-sql-server-2014 – Yort Dec 10 '15 at 04:08