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

September 10th, 2013, 06:46 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Chapter 19: Configuring the File System (unable to open DB)
I am in chapter 19 (page 757), configure the filesystem for the website.
Quote:
|
To check if the site works, open a browser and go to http://localhost. You should see the Planet Wrox website appear. To verify that everything is in order, browse through the site by requesting pages from the main menu, fi lling in the contact form, creating a new album, uploading pictures, and so on. If you get an error, refer to the section âTroubleshooting Web Server Errors.â
|
When I try http://localhost, I can see the home page, but browsing to other pages specially where DB access required, I get this error:
Quote:
|
The database 'C:\BEGASPNET\RELEASE\APP_DATA\PLANETWROX.MDF' cannot be opened because it is version 706. This server supports version 662 and earlier. A downgrade path is not supported.
|
All the pages works from Visual Studio IDE (2012 Professional).
Googling shows site attached to SQL Server 2012, so unable to downgrade.
Hope I have not missed any steps. Any suggestions to resolve this issue.
Thanks
|
|

September 10th, 2013, 11:13 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Sounds like there's a mismatch in SQL Server version. To which version of SQL Server are you attaching this database?
Imar
|
|

September 10th, 2013, 11:20 PM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
In my machine, SQL server 2008 & 2012 installed.
I want to attach DB to SQL server 2012. Tried to attach using SSMS (SQL Server Management Studio) 2012 but failed to attach, looks like it attached to 2008. Not sure yet how to check which version the DB attached to.
I can not see SSMS under All Programs - Microsoft SQL Server 2008. Any idea how to detach the DB.
In chapter 19, I have followed earlier steps to copy the site to release folder, looks like somehow it attached to earlier version of SQL server.
|
|

September 12th, 2013, 10:30 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You'll need to modify your connection strings to target the SQL Server 2012 database. Appendix B has more details.
Cheers,
Imar
|
|

September 16th, 2013, 04:09 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Thanks for your suggestions. I have followed Appendix B to create user, set database role.
Now gets different error:
[SqlException (0x80131904): Login failed for user 'PlanetWroxUser'.]
I have double checked user name, password, even created another user but same error.
Here is my connection strings:
Quote:
<connectionStrings>
<add name="PlanetWroxConnectionString1" connectionString="Data Source=.\SqlExpress;Initial Catalog=PlanetWrox;User ID=PlanetWroxUser;password=Pa$$w0rD" providerName="System.Data.SqlClient" />
<add name="PlanetWroxEntities" connectionString="metadata=res://*/App_Code.PlanetWrox.csdl|res://*/App_Code.PlanetWrox.ssdl|res://*/App_Code.PlanetWrox.msl;provider=System.Data.SqlCl ient;provider connection string="Data Source=.\SqlExpress;Initial Catalog=PlanetWrox; User ID=PlanetWroxUser;password=Pa$$w0rD;MultipleActive ResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
|
Screen cast of SSCM: http://screencast.com/t/8Lc0VHnx
Hope its not a environmental issue.
|
|

September 16th, 2013, 06:44 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Did you configure SQL Server for SQL Server Authentication? The default is Windows security only.
Also, did you add the user as both a Login to the server and a User to the database?
Imar
|
|

September 17th, 2013, 06:57 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Did you configure SQL Server for SQL Server Authentication? The default is Windows security only.
|
Yes, screencast: http://screencast.com/t/hlJicp26
Quote:
|
Also, did you add the user as both a Login to the server and a User to the database?
|
Yes, screencast: http://screencast.com/t/cf5qewAv
|
|

September 17th, 2013, 11:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Take a look at the first image you posted. The title bar says (localdb)\v11.0 while your connection strings target SqlExpress. Looks like you're configuring an incorrect instance of SQL Server.
Cheers.
Imar
|
|

September 18th, 2013, 07:01 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Thanks for your response. I have tried the server name "(localdb)\v11.0" before and was getting server not found error then I used SqlExpress.
With server name, I get following errors.
Stack Trace
Quote:
...
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)]
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6676046
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +810
...
|
Event viewer log...
Quote:
|
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
|
connectionStrings
Quote:
<add name="PlanetWroxConnectionString1" connectionString="Data Source=(localdb)\v11.0;Initial Catalog=PlanetWrox;User ID=PlanetWroxUser;password=Pa$$w0rD" providerName="System.Data.SqlClient" />
<add name="PlanetWroxEntities" connectionString="metadata=res://*/App_Code.PlanetWrox.csdl|res://*/App_Code.PlanetWrox.ssdl|res://*/App_Code.PlanetWrox.msl;provider=System.Data.SqlCl ient;provider connection string="Data Source=(localdb)\v11.0;Initial Catalog=PlanetWrox; User ID=PlanetWroxUser;password=Pa$$w0rD;MultipleActive ResultSets=True"" providerName="System.Data.EntityClient" />
|
As a beginner, the issue could be something simple I have missed. All sites works fine from VS 2012, only the release is not working.
|
|

September 18th, 2013, 09:12 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
LocalDB is designed to be used during development, and not for production (which is what you're doing when hosting it in IIS, even if it's just on your local machine).
There are a few ways to resolve this:
1. Keep using LocalDB and do as the error message says by loading the user profile. You find this setting on the Applicaton Pool in IIS. It's under Advanced Settings and its called "Load User Profile".
You should see this solution as a work around on your local machine only.
2. Switch to SQL Server / SQL Server Express. First, try logging in to SQL Server Express using SQL Server Management Studio. The correct name for an Express instanc eis .\SqlExpress. If that fails, SQL Express may not be installed so you need to do that first. Once SQL Express is installed, follow the steps for configuring the user account and roles again and then modify your connection strings so they target .\SqlExpress instead of (localdb)\v11.0. You also need to attach your databases to SQL Server first.
Chapter 19 and Appendix B have all the details. Let me know when you get stuck by posting here with the path you've chosen and a detailed description of your problems.
Cheers,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
Happs (September 22nd, 2013)
|
|
 |
|