catalyst2 community forums  

Go Back   catalyst2 community forums > Support > Database Support

Reply
 
LinkBack Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 31-07-2006, 11:59 AM   #1 (permalink)
Registered User
 
adam's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 181
Using MSSQL 2000 with .net2 (Ditching SQL express 2005)

I thought I would share this with you all

Amongst the dll and scary files installed with .net2 is a file called aspnet_regsql.exe

This will set up tables and views in your database so it can be used to work with membership roles and the like in your .net2 application.

C:\WINDOWS\Microsoft.NET\Framework\<versionNumber> \aspnet_regsql.exe -W

the -W option will bring up a wizard making it easier to set up.

Finally you need to set up your web.config file to work with your database:
Code:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <appSettings/>

  <connectionStrings>
    <add name="SkySouthDB" connectionString="Data Source=mssql.active-ns.com;Initial Catalog=skysouth;Persist Security Info=True;User ID=*****;Password=*****"
        providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <roleManager enabled="true" defaultProvider="CustomizedProvider">
      <providers>
        <add connectionStringName="SkySouthDB" name="CustomizedProvider"
          type="System.Web.Security.SqlRoleProvider" />
      </providers>
    </roleManager>


    <membership defaultProvider="CustomizedProvider">
      <providers>
        <add name="CustomizedProvider"
             type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="SkySouthDB"
             minRequiredPasswordLength="5"
             minRequiredNonalphanumericCharacters="0" />
      </providers>
    </membership>

  </system.web>
</configuration>
See: http://msdn2.microsoft.com/en-us/library/x28wfk74.aspx
__________________
ASP.net is the reason why I am learning PHP
adam is offline   Reply With Quote
Old 01-08-2006, 09:56 PM   #2 (permalink)
Administrator
 
WhiskyFudge's Avatar
 
Join Date: Oct 2003
Posts: 1,484
The same method but with different options can also be used for personalisation and the other things (can't think of them in the top of my head) where asp.net2 is good enough to create database elements for you.
__________________
Jason Robbins
jason@catalyst2.com
WhiskyFudge is offline   Reply With Quote
Old 15-08-2006, 08:42 AM   #3 (permalink)
Registered User
 
Join Date: Aug 2006
Posts: 10
Important addition when using membership API

I have recently had a problem when using Users and Roles in my ASP.NET 2.0 application with the Login control. I used the aspnet_regsql.exe application to populate my SQL Server 2000 database on the catalyst servers with the tables necessary to use the membership API. I then configured my application's web.config to use this database for membership and roles similar to the way mentioned by Adam above.

I then used the ASP.NET 2.0 Website Administration tool to add users and roles to the database.

When I added a login control to my website I tested it locally and everything was working great. The website running on my local machine was connecting up to the SQL Server database on the catalyst servers fine and using the users and roles contained within successfully.

However, when I loaded my website up to the catalyst servers and called the login page it failed to authenticate my username!

I eventually found a blog by ASP.NET 2.0 guru Scott Guthrie entitled "Always set the 'applicationName' property when configuring ASP.NET 2.0 Membership and other Providers".
http://weblogs.asp.net/scottgu/archi...Providers.aspx

Adding the applicationName attribute to my custom membership and role provider fixed the problem. My website authentication now works when run locally and remotely on the catalyst server.

Just thought I would pass this on to save anyone else wasting time with it!
GalaxyTech is offline   Reply With Quote
Old 15-08-2006, 09:33 AM   #4 (permalink)
Administrator
 
WhiskyFudge's Avatar
 
Join Date: Oct 2003
Posts: 1,484
Thank-you for that GalaxyTech. For any asp.net dev's out there I would strongly recommend reading Scott G's blog. He's an very inteligent guy who is in charge of pretty much everything webby MS do (asp.net, atlas, IIS, etc)
__________________
Jason Robbins
jason@catalyst2.com
WhiskyFudge is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:28 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.