469,920 Members | 2,215 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

How to use MS Access DB for ASPNET Application Services (membership, profile, etc)

A lot of times, web hostings for ASPNET 2.0 will offer only MS Access
DB for database for basic plan, a question often asked is how can I use
the membership services, role, web parts services, etc for this MS
Access db. Well, microsoft offers a download sample. Instructions
are below.

HOW TO USE MS ACCESS DB FOR ASPNET APPLICATION SERVICES ( membership,
profile, roles, etc providers)

1. Download the Sample Access Provider from microsoft.

http://msdn.microsoft.com/vstudio/eu...f-027e6c8e15d8
This will install a VSI which you can open in Visual Studio 2005.
It contains a sample web.config as well as sample ASPnetDb.mdb
NOTE: web.config has an incorrect provider type. For example:

type="Samples.AccessProviders.AccessMembershipProv ider,
SampleAccessProviders"

"SampleAccessProviders" should have been "ASP.NET Access Providers"
because
that is the name of the DLL created by this class library.
You can use either of this:

1. Change the name of DLL. (by right-clicking on project, in
Applications tab, change the type to 'SampleAccessProviders'.
or
2. Change every occurrence of "SampleAccessProviders" in web.config
with "ASP.NET Access Providers"

In any case, you should be able to get rid the "unable to load Type"
runtime error.


You should create the DLL by compiling the class library project.
2. Create a new web site. Copy ASPnetDb.mdb in the 'App_Data'
directory.
Incorporate the sample web.config file in the class library into the

web.config file in your new website.

3. Select your website in visual studio, Launch ASPNET Configuration
Wizard.
You should be able now to add security.


For example, I changed the namespace of the Sample access providers
project to 'AccessProviders' and also changed the DLL to
'ASP.NET.AccessProviders.dll'

Here is my working sample web.config


<configuration>
<connectionStrings>
<add name="AccessFileName"
connectionString="~/App_Data/ASPNetDB.mdb"
providerName="System.Data.OleDb"/>
</connectionStrings>
<system.web>
<authentication mode="Forms">
<forms loginUrl="mylogin.aspx" defaultUrl="Login.aspx"/>
</authentication>

<membership defaultProvider="AccessMembershipProvider">
<providers>
<clear/>
<add name="AccessMembershipProvider"
type="AccessProviders.AccessMembershipProvider,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresUniqueEmail="false"
requiresQuestionAndAnswer="false"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
applicationName="SampleSite"
hashAlgorithmType="SHA1"
passwordFormat="Hashed"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="AccessRoleProvider"
cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All">
<providers>
<add name="AccessRoleProvider"
type="AccessProviders.AccessRoleProvider,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"/>
</providers>
</roleManager>
<profile enabled="true" defaultProvider="AccessProfileProvider">
<providers>
<add name="AccessProfileProvider"
type="AccessProviders.AccessProfileProvider,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"
description="Stores and retrieves profile data from
an ASP.NET_Access_Providers database."/>
</providers>
<properties>
<add name="FriendlyName" type="string" allowAnonymous="true"
serializeAs="String"/>
<add name="Height" type="int" allowAnonymous="true"
serializeAs="String"/>
<add name="Weight" type="int" allowAnonymous="true"
serializeAs="Xml"/>
</properties>
</profile>
<anonymousIdentification enabled="true"
cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="None" domain=""/>
<webParts>
<personalization
defaultProvider="AccessPersonalizationProvider">
<providers>
<add name="AccessPersonalizationProvider"

type="AccessProviders.AccessPersonalizationProvide r,
ASP.NET.AccessProviders"
connectionStringName="AccessFileName"
applicationName="SampleSite"/>
</providers>
</personalization>
</webParts>

<!--
<trust level="Medium"/>
-->

<compilation debug="true"/>
</system.web>
</configuration>


You can also put the absolute path in the connection strings
<connectionStrings>
AccessFileName"
connectionString="D:\Clients\C240\msite.com\databa se/ASPNetDB.mdb"
providerName="System.Data.OleDb"/>
</connectionStrings>



--------------------------------------------------------------------------------
Last Updated 7/5/2006 7:19:21 AM by 'Editor'
Home | Edit page | List pages | Recent pages | RSS Search for:

Jul 5 '06 #1
0 6022

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Keith Jakobs, MCP | last post: by
29 posts views Thread by Patrick | last post: by
2 posts views Thread by Runsrealfast | last post: by
reply views Thread by =?Utf-8?B?QV9SZXB1YmxpY2Fu?= | last post: by
5 posts views Thread by Rory Becker | last post: by
3 posts views Thread by Oriane | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.