Wrox Programmer Forums
|
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
 
Old June 6th, 2013, 05:57 PM
Registered User
 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 16: Login tries to create database

Imaar,
When I try to execute the login or the create user functions, I get this error:

Cannot create file 'C:\BegASPNET\Site\App_Data\PlanetWrox.mdf' because it already exists. Change the file path or the file name, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

It is trying to create 'C:\BegASPNET\Site\App_Data\PlanetWrox.mdf' and cannot because it already exists.

I set the web.Config as follows:

<connectionStrings>
<add name="PlanetWroxConnectionString1" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirec tory|\PlanetWrox.mdf;Integrated Security=True" 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=&quot;data source=.;initial catalog=PlanetWrox;persist security info=True;user id=x2user;password=xedron02;MultipleActiveResultSe ts=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
.
.
<system.web>
<authentication mode="Forms" />
.
.
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="PlanetWroxConnectionString1" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvid er, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="PlanetWroxConnectionString1" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="PlanetWroxConnectionString1" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProv ider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="PlanetWroxConnectionString1" />
</providers>

I do not see a reason why it would try to create a database that exists.

Can you advise?

Thanks,

Rich Klein
 
Old June 7th, 2013, 02:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Rich,

You seem to be using two different versions of SQL Server: Local DB for the PlanetWroxConnectionString1 and a unnamed instance (.) for the
PlanetWroxEntities. On the last instance, you attached a database and called it PlanetWrox. Is that database pointing to the same .MDF in the site's App_Data folder?

If so; this makes sense; you can't share the MDF file like this across two instances of SQL Server. Try pointing PlanetWroxConnectionString1 to the same instance of SQL server (or let PlanetWroxEntities point to LocalDB as well) and see if that fixes it.

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!
 
Old June 7th, 2013, 08:43 AM
Registered User
 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Imaar. Both of those should be pointing to the same place, but I'll clean it up and try again and let you know.

Rich
 
Old July 8th, 2013, 05:25 PM
Registered User
 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Just following up

Sorry, got busy at work. I'll post when I can work on this again.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 16 'Register' does not write to database dako3256 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 May 19th, 2010 05:02 AM
Chapter 16 Accessing Database Bruce A Smith BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 7 July 12th, 2009 01:19 PM
Chapter 16: Using Excel OM to Create a new workbook langley111 BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 0 July 5th, 2009 07:54 PM
Chapter 16 Login/Logout Issues tenjinspen BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 June 12th, 2008 04:11 AM
Permissions required to create Database Login mvsuresh01 SQL Server 2005 1 October 19th, 2006 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.