[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

sqlexpress with asp.net role & membership

Posted on 2010-04-07
3
Medium Priority
?
386 Views
Last Modified: 2012-05-09
This is my platform for this small website:

IIS7
SQL Express 2008
developed by Visual Studio 2008 web express

And this is how I run my website:

The database is automatically created by visual web studio, as a MDF file inside of App_Data, I named it database.mdf
I upload every files via ftp, include the MDF file, and change the app_data folder writable from Network Services Account
I added following line at web.config:
<add name="iConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True"  providerName="System.Data.SqlClient" />

The website runs smoothly, no problem at all.

The problem came when I start use the Roles & Memberships, the visual web studio express automatically create another database file, named Aspnetdb.mdf, and stores everything about roles and memberships to that database.

My question is: How can get rid of the aspnetdb.mdf, and use my own database.mdf to store Roles and Memberships?

Here are steps I've done and searched, and it's not working.

1.  "aspnet_regsql.exe" is the tools that ppl tell me to use, to make my database.mdf capable to run the Roles and Memberships. Well, when I try to use the aspnet_regsql.exe, it couldn't even find my database.mdf.
2.   I tried manually rename the aspnetdb.mdf, but it doesn't work this way, everytime the website will try to create aspnetdb.mdf by itself, i think i need to modify some line in web.config?

any solution would be helpful, but make sure you understand my develop environment, thanks in advance
0
Comment
Question by:joeylu
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 2000 total points
ID: 30086005
Try using sql mangmt express to mount your database and then do a regsql.
Then in your web config you need to modify the rolse and membership provider.
Also, the web.config probably created a conn string called: SqlRoleManagerConnection, you need to alter that to point to your database.
I can't remember if IIS7 uses the role provider and membership provider config options but you need to check those to make sure they point to the above connection string.

Another way would just be to transfer the contents of database.mdf over to the file it is creating and point your primary connectionsting to it.

Hope this helps,
Dustin
0
 
LVL 3

Expert Comment

by:chrisgreaves
ID: 30137075
Sorry I don't have a solution for you but I am curious to know why you do not want Aspnetdb.mdf. It seems to encrypt all the vital info, manage the roles etc, doing all the heavy work for us.
Chris
0
 
LVL 14

Expert Comment

by:Dustin Hopkins
ID: 30147105
Chris,
Generally most small to medium websites don't need multiple databases to maintain the user info and website data separately, since it's easier to reference that data whilst in the same database. Also since both databases are running on the same instance of sql, so you wont see much performance gain from seperating the databases.

In Joeys case, it sounds like he had already created his primary database and didn't want .net to create a second one for roles and mem.

So all he needed to do was either attach his mdf to sql, run a regsql, then alter his webconfig to point to his mdf in the provider conn string.
Or copy all of his existing database objects to aspnetdb, then alter his normal connstring to point to the aspnetdb.mdf file.

As for encrypting vital, managing, ect. When you use aspnet_regsql.exe it creates all the tables, views, functions, ect. that are in the aspnetdb on what ever database you specify, basically making it an aspnetdb database.( Easier if you have already created a db and data, but haven't setup roles and providers.)

Hope this helps,
Dustin
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question