 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : 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
|
|
|
|
|

June 21st, 2014, 06:47 PM
|
|
Registered User
|
|
Join Date: May 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 12 Databases
In chapter 12 on pages 406-407, when I dropped the mdf file into the App_Data folder, I got an error that something to the effect of "SQL Server Express 2005 or 2008 must be installed to support this file type". So I installed SQL Server 2012 Express. Since then, I have worked through a couple of different errors.
Anyway, when I try to double-click on the mdf file in Database Explorer it gives me this error:
"Unable to open the physical file 'filePath\filename'. Operating system error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file 'filePath\fileName' failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
I have Visual Studio 2010 Ultimate, SQL Server 2008 r2, and SQL Server 2012 Express installed on my Windows 7 operating system.
Any ideas?
|
|

June 23rd, 2014, 10:24 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Does the following post help you with this: Connecting to Database
That could be a good starting point for trouble shooting.
Cheers,
Imar
|
|

June 23rd, 2014, 10:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In addition, you may want to check out some other posts on this topic:
https://www.google.com/?gws_rd=ssl#q...tem+error+5%22
It seems that people get this error for different reasons, so you may need to do some troubleshooting to figure out what applies to you.
Cheers,
Imar
|
|

June 23rd, 2014, 12:12 PM
|
|
Registered User
|
|
Join Date: May 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In relation to questions you asked in a different thread:
1) I don't know which SQL Server I am targeting; it just says Data Connections in my Server Explorer.
2) I had already set the permissions in the App_Data folder so that Users(Kurt-PC\Users) could modify contents in the folder.
3) In SQL Server Management Studio, when I log into server "\SQLSERVEREXP2012" I do see the database file. When I log into the parent node "\SQLEXPRESS" I do not see the mdf; nor do I see it in the local "." server, or on a pipe I created called something like "\\.\pipe\...\tsql\query".
When I ran Visual Studio as an administrator I got a new error:
"The database 'databasePath\databaseName' cannot be opened because it is version 706. This server supports version 662 and earlier. A downgrade path is not supported.
Could not open new database 'dbPath\dbName'.
CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file 'dbPath\dbName' failed.
A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
What I get from this new error is that it is trying to access it via Sql Server 2008 r2 and not Sql Server 2012 Express.
What do you think?
|
|

June 23rd, 2014, 01:25 PM
|
|
Registered User
|
|
Join Date: May 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I went under Tools | Options | Database Tools | Data Connections | SQL Server Instance in Visual Studio and changed the server instance to ".\SQLSERVEREXP2012". I now get an error message that reads "Instance Failure" when I double click the database file from Server Explorer.
If I double-click the file in the App_Data folder I still get the error message:
"Connections to SQL Server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded at...".
I don't know if I should try installing Sql Server 2008 or 2005 Express to see if that resolves the issue.
|
|

June 23rd, 2014, 05:40 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Have you tried (LocalDB)\v11.0 as the SQL Server instance under Tools | Options? You don't need an older version of SQL Server, this should work with more recent versions too.
Cheers,
Imar
|
|

June 23rd, 2014, 09:21 PM
|
|
Registered User
|
|
Join Date: May 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Database File
Quote:
Originally Posted by Imar
Have you tried (LocalDB)\v11.0 as the SQL Server instance under Tools | Options?
|
Ok so I set the server instance to "(LocalDB)\v11.0" as you suggested above. I put it in exactly as you have written it. Should I have modified a little to fit my machine? Anyway, the result is the same when I double-click on the database file in Server Explorer: "Instance Failed".
Have you ever seen SQL Server confused about who/what it is? This has happened on two separate occasions: one today and one about a week ago. When running Sql Server Management Studio 2012 tool (my 2008 has a different layout than 2012), I requested the @@version in the SQLEXPRESS server and in the SQLSERVEREXP2012 and it said that I was using "Microsoft SQL Server 2008 (SP2)-10.0.4000.0 (X...".
When I closed it and reopened it again, it said 2012 Express like it was supposed to.
I'm not fibbing on this; have pictures to prove it.
|
|

June 25th, 2014, 10:06 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It looks like your SQL Servers are messed up. Maybe it's an option to backup all your databases, uninstall all instances of SQL Server, reboot and then install the one you need? 2010 as the Express edition and then any other version side by side?
>> Should I have modified a little to fit my machine?
Nope; that's the fixed name of the developer edition. However, it may not be installed on your machine. It gets installed with recent versions of VS but you may be using an older version of VS so ignore this comment ;-)
Cheers.
Imar
|
|
 |
|