 |
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

April 12th, 2014, 05:02 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Connecting to Database
I'm working on Chapter 13 trying to connect to the database that was created in Chapter 12. I see the database in the Solution Explorer and I double click on the database file as instructed in Step #6 on page 444. The Server Explorer opens and the database is listed under "Data Connections" but the icon has a red "X" over it. When I hit the refresh button, I get an error message as follows:
"Unable to open the physical file "C:\Planet_Wrox\App_Data\PlanetWrox.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file C:\Planet_Wrox\App_Data\PlanetWrox.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
I suspect it has something to do with Administrator permissions or something along those lines, but I'm not sure how to clear this up.
Might also be the "connectionstring" DataSource address in the webconfig file.
Thanks for any help you might be able to give.
Last edited by Psyclist; April 12th, 2014 at 05:34 PM..
|
|

April 13th, 2014, 04:14 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
A couple of things to check / questions:
1. Which version of SQL Server are you targeting? Express, or Local DB? And are you using Visual Studio 2013?
2. What are the permissions for the folder C:\Planet_Wrox\App_Data\ on disk? You can open the Properties of the folder in Windows and then look under the Security tab.
3. When you log in to SQL Server using Management Studio, do you see your database attached there already?
Cheers,
Imar
|
|

April 13th, 2014, 12:29 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
The only option I get is SQLExpress. I don't get the option the Local DB option. It's SQL Server 2012 which is the version the book says to download.
As for permissions in question #2, "SYSTEM" is listed along with myself (my login name for windows), and Administrator (I'm the only user of this laptop, so I assume I'm logging in as the Admin).
#3: I uninstalled and reinstalled SQL Server, so at present, no I don't see it there. On the previous installation, I created the database/tables as instructed in chapter 12 and had no problem with that.
Thank you.
|
|

April 13th, 2014, 02:26 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Which version of Visual Studio are you using? LocalDB should be installed automatically with VS 2013.
That said, try running VS as an Administrator (right-click it on the Start Menu and choose Run as Administrator). Does that make a difference?
Imar
|
|

April 13th, 2014, 02:48 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Ooops, sorry. Misread that.
I'm using "Visual Studio Express for the Web 2013."
|
|

April 13th, 2014, 02:51 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Get the same thing when I start it as Administrator.
|
|

April 13th, 2014, 02:52 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
Actually, now I don't see the database in the Server Explorer. I just see the connection string name (PlanetWroxConnectionString1). It has the red "X". I don't see LocalDB under "Servers" either.
Last edited by Psyclist; April 13th, 2014 at 03:00 PM..
|
|

April 13th, 2014, 03:32 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
A few things to check:
1. What happens when you double-click the MDF in the App_Data folder.
2. What do you have under Tools | Options | Database Tools | Data Connections | SQL Server Instance in Visual Studio?
3. When you use SQL Server Management Studio, what happens wen you try to connect to the server name (LocalDB)\v11.0 ?
Imar
|
|

April 13th, 2014, 03:56 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
When I double-click on the database file in the Solution Explorer, I get a dialog box with the following content:
"Unable to open physical file "C:\Planet_Wrox\App_Data\PlanetWrox.mdf". Operating system Error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file C:\Planet_Wrox\App_Data\PlanetWrox.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
I click on the OK button to dismiss this dialog box and Server Explorer shows "PlanetWroxConnectionString1" under "Data Connections", and "laptop" under "Servers".
Question #2: (LocalDB)\v11.0 is in the box below "SQL Server Instance Name".
Question #3: When I open SQL Server Management Studio, a dialog box opens - "Connect to Server". In the "Server Name" dropdown it defaults to LAPTOP/SQLEXPRESS. When I click on the arrow to dropdown options, the only other item in the list is <browse for more...>. When I click on that a dialog box opens with two tabs, one labeled, "Local Servers" which has "Database Engine" with a + sign to the left of it. When I click on the + sign, only LAPTOP\SQLEXPRESS displays. The other tab is "Network Servers" and has "Database Engine" in it with a + sign to the left. When I click on the +, only LAPTOP displays.
I connect to LAPTOP\SQLEXPRESS and in the "Object Explorer" window, it says "LAPTOP\SQLEXPRESS(SQL Server 11.0.2100 - laptop\MyName)
Last edited by Psyclist; April 13th, 2014 at 04:07 PM..
|
|

April 13th, 2014, 05:04 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
For item 3, try entering the name I suggested in the Server name box manually
Does that give you access to Local DB?
Imar
|
|
 |
|