Need Help With Custom Profile Providers

P

pbd22

Hi.

I am trying to roll my own profile provider and have some questions
just so I make sure
I understand what I am doing. I have followed the example on MSDN
here:

http://msdn.microsoft.com/en-us/library/8zs47k7y(VS.85).aspx

Prior to reading about custom profiles, I had my own "Users" table in
my database and
wasn't sure what to do with this table after reading through the
Custom Profile Provider
example. I guessed that the table in the example, ProfileData, was
meant to store
the same kind of data I previously stored in my Users table so I moved
all the columns
from Users into ProfileData (Illustrated below in 'ProfileData').

What I am unclear on is what is the point of of separating the
Profiles table (below) from the
ProfileData table per the MSDN example? I understand that Profiles
serves as the PK table to which all related entities can map but what
is so unique about its column fields that they cannot also be put in
the ProfileData table?

The way I am currently looking at it:

1) When the user registers, a new record is created int he Profile
table and his registration information is stored in the ProfileData
table.

2) When the user logs in, credentials are checked in ProfileData and
then further information
is stored as a session in Web.config (shown below - is this right?)
for fast access.

I feel like I am missing some of the basics here (am I?) and
appreciate any help along those lines. Thanks in advance.

TABLES:

USE [DBDev]
GO
/****** Object: Table [dbo].[Profiles] Script Date: 12/30/2008
16:42:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Profiles](
[profileid] [int] IDENTITY(1,1) NOT NULL,
[username] [varchar](50) COLLATE Latin1_General_CI_AI NOT NULL,
[applicationname] [varchar](50) COLLATE Latin1_General_CI_AI NOT
NULL,
[isanonymous] [bit] NULL,
[lastactivitydate] [datetime] NULL,
[lastupdateddate] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
[profileid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
CONSTRAINT [PKProfiles] UNIQUE NONCLUSTERED
(
[username] ASC,
[applicationname] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

------------------------------------------------------------------------------------------------------------------------------------

USE [DBDev]
GO
/****** Object: Table [dbo].[ProfileData] Script Date: 12/30/2008
16:43:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[ProfileData](
[profileid] [int] NOT NULL,
[lastname] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[firstname] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[varchar](50) COLLATE Latin1_General_CI_AI NOT NULL,
[alternateemail] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[password] [varchar](50) COLLATE Latin1_General_CI_AI NOT NULL,
[securityquestion] [varchar](50) COLLATE Latin1_General_CI_AI NOT
NULL,
[securityanswer] [varchar](50) COLLATE Latin1_General_CI_AI NOT NULL,
[zipcode] [int] NOT NULL,
[birthmonth] [tinyint] NOT NULL,
[birthday] [tinyint] NOT NULL,
[birthyear] [int] NOT NULL,
[gender] [varchar](10) COLLATE Latin1_General_CI_AI NULL,
[city] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[state] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[country] [varchar](50) COLLATE Latin1_General_CI_AI NULL,
[registerdate] [datetime] NOT NULL,
[editdate] [datetime] NULL,
[confirmed] [bit] NULL CONSTRAINT
[DF__ProfileData__confirmed__4CC05EF3] DEFAULT ((0)),
CONSTRAINT [PK_ProfileData] PRIMARY KEY CLUSTERED
(
[profileid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
CONSTRAINT [IX_email] UNIQUE NONCLUSTERED
(
[email] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
USE [TrezoroDBDev]
GO
ALTER TABLE [dbo].[ProfileData] WITH CHECK ADD CONSTRAINT
[FKProfiles2] FOREIGN KEY([profileid])
REFERENCES [dbo].[Profiles] ([profileid])

-----------------------------------------------------------------------------------------------------------------------------------------

WEB.CONFIG:

<profile defaultProvider="DBDev">
<providers>
<clear />
<add
name="DBDev"
type="ProfileProvider.Provider.ProfileProvider"
connectionStringName="cDB"
applicationName="MyApplication"
/>
</providers>
<properties>
<add name="lastname"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="firstname"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="email"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="securityquestion"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="securityanswer"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="zipcode"
type="int"
defaultValue="[null]"
allowAnonymous="true" />
<add name="birthmonth"
type="int"
defaultValue="[null]"
allowAnonymous="true" />
<add name="birthday"
type="int"
defaultValue="[null]"
allowAnonymous="true" />
<add name="birthyear"
type="int"
defaultValue="[null]"
allowAnonymous="true" />
<add name="gender"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="city"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="state"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="country"
type="string"
defaultValue="[null]"
allowAnonymous="true" />
<add name="registerdate"
type="datetime"
defaultValue="[null]"
allowAnonymous="true" />
</properties>
</profile>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top