Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 12th, 2014, 06:02 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default 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 06:34 PM.
Reply With Quote
  #2 (permalink)  
Old April 13th, 2014, 05:14 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,955
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old April 13th, 2014, 01:29 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #4 (permalink)  
Old April 13th, 2014, 03:26 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,955
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old April 13th, 2014, 03:48 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Ooops, sorry. Misread that.

I'm using "Visual Studio Express for the Web 2013."
Reply With Quote
  #6 (permalink)  
Old April 13th, 2014, 03:51 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Get the same thing when I start it as Administrator.
Reply With Quote
  #7 (permalink)  
Old April 13th, 2014, 03:52 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

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 04:00 PM.
Reply With Quote
  #8 (permalink)  
Old April 13th, 2014, 04:32 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,955
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #9 (permalink)  
Old April 13th, 2014, 04:56 PM
Authorized User
Points: 129, Level: 2
Points: 129, Level: 2 Points: 129, Level: 2 Points: 129, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

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 05:07 PM.
Reply With Quote
  #10 (permalink)  
Old April 13th, 2014, 06:04 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,955
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

For item 3, try entering the name I suggested in the Server name box manually

Code:
 (LocalDB)\v11.0
Does that give you access to Local DB?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to Database bryantms ASP.NET 3.5 Basics 3 July 9th, 2008 01:34 AM
connecting to database stealthdevil Visual Basic 2005 Basics 2 November 5th, 2007 01:31 PM
Connecting to a database mfos Classic ASP Basics 0 December 20th, 2006 07:59 AM
connecting to a database nehalw VB.NET 0 January 5th, 2005 05:59 AM
database connecting princeofdhump Classic ASP Databases 3 August 7th, 2004 03:46 AM



All times are GMT -4. The time now is 10:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.