I have spent most of the day struggling with the SQL Server connection.
Amongst other things, I have uninstalled and re-installed SQL Server (2008 R2 Express) - takes ages!
All that I am looking for is a reliable and foolproof way to link a new ASP.NET 4 website to an existing database and then to develop the website against the database.
Now I know how to design and create databases and then work with them in SQL Server Management Studio. (been doing that for years)
So what I'm having trouble with is linkiing a new website to an existing database.
Lets start with the P 406 Try-it-out
Step 4: When I doublle click I get the error message:
"Failed to generate a user instance of SQL Server due to a failure in starting the process for the user interface."
In addition the Database Explorer appears and in it is:
Data Connections> PlanetWrox.mdf
Then I right-click on "PlanetWrox.mdf" and choose "modify connections" in the popup dialog box.
Then, in the "Change Data Source" dialog box I change the Data source
From: Microsoft SQL Server Database File (SqlClient)
To: Microsoft SQL Server
The next dialog box is called "Modify Connection"
In the "Server Name" textbox I click on the down arrow at the right.
After 20 seconds or so I see the text "D1525\SQLEXPRESS"
(D1525 is my computer name)
I choose the radio button next to "Use Windows Authentication".
(Because that is how I set it up when I installed SQL Server)
If I already had a database, then I would "Select or enter a database name" [Note: This actually works with one of my own databases but I don't know how to get the database to appear in the App_Data folder - But do I need this?]
(This shows the databases that are registered with the SQL Server .
Note that the "master, model msdb and temp" options are system databases and not to be touched.)
Since this is a new database, I choose "Attach a database file" then click the browse button and go to C:\BegASPNET\DatabaseTest\App_Data.
Then highlight the PlanetWrox.mdf db that is in this folder is in this folder.(From Step 3) then click "open"
BUT when I click on "Test Connection" or "OK" I get a complicated error message that reads: "Unable to open the physical file......Operating System Error 5 ....
PS: Here is some data that I hope will be helpful:
1. SQL server version:
SQL Server 2008 R2
2. SQL Instance:
3. What happens when you create a brand new web site, add App_Data and a SQL Server database and open that. Does that work?
* Same problem.
4. Are you trying this out with your own database, or with one from the download?
5. Can you log in using SQL Server Management Studio?