Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Changing Membership Provider ASP.NET 2.0
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing Membership Provider ASP.NET 2.0

 Post Reply Post Reply
Author
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Topic: Changing Membership Provider ASP.NET 2.0
    Posted: 14 November 2005 at 8:13pm
Okay, heres my dilemma. When I created my application Visual Web Developer Express automatically generated the ASPNETDB.MDF database. I created a separate database - DATABASE.MDF which stores most of the important info. (other than user info.). Now I want to combine those two databases into one - preferrably ASPNETDB.MDF into DATABASE.MDF. I don't need any of the information that is currently in ASPNETDB, and I am wondering, is there a way to have the SqlMembershipProvider point to DATABASE.MDF and automatically recreate all the tables, etc. it made in ASPNETDB.MDF?
David.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2005 at 1:36pm

create an empty database

run aspnet_regsql.exe which is located in the 2.0 Framework Directory, this will create all aspnet tables.
 
Then in the web.config you need to create our providers someting like this:

<connectionStrings>
  <remove name="LocalSqlServer" />
  <add name="SqlServices" connectionString="Data Source=yourconnectionString here" />
   </connectionStrings>
<!-- Now the providers, configured to manually look at yours-->
<membership defaultProvider="csIntra">
   <providers>
    <clear/>
    <add connectionStringName="SQLServices" applicationName="csIntra" name="csIntra" type="System.Web.Security.SqlMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false"/>
   </providers>
  </membership>
  <roleManager enabled="true" defaultProvider="csIntra">
   <providers>
    <clear/>
    <add connectionStringName="SQLServices" applicationName="csintra" name="csIntra" type="System.Web.Security.SqlRoleProvider"/>
   </providers>
  </roleManager>
  <profile defaultProvider="csIntra" enabled="true">
   <providers>
    <clear/>
    <add name="csIntra" applicationName="csIntra" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SQLServices"/>
   </providers>
   <properties>
    <add name="office" type="System.String"/>
    <add name="department" type="System.String"/>
    <add name="DefaultProducts" type="System.Collections.ArrayList"/>
   </properties>
  </profile>
  <webParts>
   <personalization>
    <providers>
     <clear/>
     <add connectionStringName="SQLServices" name="AspNetSqlPersonalizationProvider" applicationName="csIntra" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </providers>
 
There is some of my stuff in there you may need to take out but hope it gives you an idea.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2005 at 1:36pm
Really sorry for the bad paste but if you copy paste it into your web.config it should format fine.
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2005 at 5:21pm
Thanks Michael. The problem is I already have a database and I just want to add the schema to that database. Its a SQL Server 2005 Express db just like ASPNETDB.MDF. I attempted using the instructions at the link below, but it won't work. http://weblogs.asp.net/lhunt/archive/2005/09/26/425966.aspx
David.
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2005 at 11:36pm
I believe I actually got the info. to copy into the database, I just need to know how to make it so that the SQL Express Membership Provider points to the new SQL Server Express database I have instead of the old one.
In other words, all the tables are the same names, its just that the database is now database.mdf instead of ASPNETDB.MDF.
David.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2005 at 9:36am
For this you can use the web.config example I posted above. I will let you point to a different DB
Back to Top
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2005 at 11:14pm
Thanks. The app. works now. ;-)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.