Avatar of hconant
hconant
Flag for United States of America asked on

Changing ASP.net website admin tool ASPNETDB default file

I am trying to use a shared server with an ASP.net site and SQL DB's.  The ASP.net WAT (website administration tool=WAT) creates a default db, ASPNETDB.mdf for its security, role, management settings.  This file conflicts with an existing file of same name.  How do you change the default WAT *.mdf?
ASP.NETMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
hconant

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
naspinski

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nmarun

Open the SQL Server Management Studio, connect to the server, open up the databases section, right click on the database and rename.
nmarun

You could also do it through query analyzer:
http://msdn.microsoft.com/en-us/library/ms186217.aspx
hconant

ASKER
Before I play with this, it can't be as simple as changing the aspnetdb.mdf file name, can it?  Naspinski's solution appears to look like it will work, but will the connection string reconfigure itself accordingly just by a rename without the manual rework?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
nmarun

I'm not sure why it won't work if you change the database name by either of the ways mentioned above and modify the connection string, perhaps Naspinski could through some light on this.
naspinski

By default, all .Net Roles and Users are kept in the ASPNET.mdf file that is referenced by the default connection string that is, for all intents and purposes, hidden (in the machine.config?).

If you want to change where these permissions are held, you simply remove and replace the connectionstring, though the DB must be the *exact* schema of the original file.
hconant

ASKER
The nmarun solution didn't work.  Dot net simply created a new ASPNETDB file and looked at that, which was obviously emptly.  Going to play with naspinski's solution now. (actually after breakfast)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
hconant

ASKER
Houston, we have a problem.  No matter what I do with this so far, .net WAT always recreates a new management db named ASPNETDB.mdf.  I have renamed it, deleted it, changed all the connection strings, blah blah blah.  Interestingly, when I look at the stock .net, after setting up roles and letting it configure its aspnetdb.mdf, I do not find any reference to it (ASPNETDB.mdf) in the web.config file.  I need to find out where the WAT is creating and referencing this file.  To make it simple, how about go back to simply renaming the aspnetdb.mdf and having WAT use it, even on the local SQL server.  I have not even accomplished that yet, and I believe it is the key to the issue.  We can address relocating it later, which I believe can be accomplished via the connection string changes.
SOLUTION
guru_sami

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
hconant

ASKER
I've created a new db ASPBIS.mdf which is attached to the hcdesktop\sqlexpress server instance.  I've changed the connection string in the web.config file as shown in the first code snippet below.  I still got this error when trying to run security WAT.
This is the error I got.

The following message may help in diagnosing the problem: An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax. Parameter name: connectionString :

I then changed the connection string to what shows in the second code sample which did work.  I got that code by copying the structure from a working .net WAT.  It would be nice to know why the second code worked, and also since the second code is not what is shown in any of the other samples or tutorials I looked at.  Most signficantly being "AttachDBFilename=|DataDirectory|ASPBIS.mdf" as compared to "="Data Source=hcdesktop2\sqlexpress;initial Catalogue=ASPBIS"

Thanks
rem: CODE THAT DIDN'T WORK
<remove name ="LocalSqlServer" />
		<add name="LocalSqlServer" connectionString="Data Source=hcdesktop2\sqlexpress;initial Catalogue=ASPBIS;Integrated Security=True" providerName="system.data.sqlclient" />
		
			 </connectionStrings>
 
THE FOLLOWING CODE DID WORK, BUT I AM NOT SURE WHY
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ASPBIS.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
	</connectionStrings>

Open in new window

hconant

ASKER
Additional info. The code I used as an example I actually copied from the machine.config file, pasted it into the web.config file, and just simply changed the original ASPNETDB file name with the new ASPBIS db I created and associated with the aspnet_regsql utility.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes