In this example i m going to describe how to change and use custom Database with Login Control in ASP.NET.
First of all you need to create DataBase schema for membership.
For this create a DataBase in sql server with any name you want.
Now open Visual studio command prompt and type aspnet_regsql , press enter
this will open wizard window to setup database for membership provider
Alternatively you can Go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and run aspnet_regsql.exe from there
Follow the steps according to images
Choose your Database Server and DataBase Name
Now open web.config file and write below mentioned code
Add connection string
Now add this code in System.web section of web.config<connectionStrings> <add name="ConnectionString" connectionString="server=AVDHESH\SQLEXPRESS; database=CustomMembership;uid=amit;password=password;"/> </connectionStrings>
<roleManager defaultProvider="CustomProvider"> <providers> <add connectionStringName="ConnectionString" name="CustomProvider" type="System.Web.Security.SqlRoleProvider" /> </providers> </roleManager> <membership defaultProvider="CustomMembershipProvider"> <providers> <add name="CustomMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ConnectionString" /> </providers> </membership>
After this click on website menu in Visual Studio and select ASP.NET Configuration
GO to Provider Tab and click on Select a different provider for each feature (advanced) option
Now create users by going to security tab
Your custom membership provider with your own custom databse configuration is done
Build and test the application
![]() |
||
|
|
![]() |
|
| add to del.icio.us saved by 0 users |










8 comments:
You can't believe how much you just helped me. Thanks you so much.
hey amit,
thanks.
u saved many hours of mine.
this is very good.I used it in my application.when i run my website using visual Studio connected with remote db it works nice but when i deploy it on net than it shows password is incorrect.i tryed it more than two user but the problem is same.please help i need help very urgent.plzzzzzzzzzzzzzz.kshatriya2255@gmail.com
@abhishek Singh:
Please check the connection string in Your web.config file under membership defaultProvider="CustomMembershipProvider" section
Hi Amit,
Thanks for breaking this down so nicely. I book-marked you on Stumble and Digg. Good work!
Sean
@Sean Olson:
Thanks a lot for the appreciation and favor :)
Keep visiting
thanks amit!
i will sleep today properly after
one week .
thnks again
uzz
good looking
Post a Comment