SQL Connection Error on Profile.Save()

G

Guest

Hi folks,

I am trying to use the new User Profile functionality in ASP.Net 2, and on
initial impression, it looked simple enough to use.

But I seem to be getting in a bit of a mess as to what is going on
internally, making it difficult for me to trace the SQL connectivity errors I
seem to be getting suddenly.

I have my own SQL Express database, on which I've run aspNet_regsql utility
to create the user membership tables.

The ASP.Net Configuration tools connects fine to my database, and allows me
to create users and roles without a problem.

I have also implemented some custom code which programmatically creates
users and associates them with roles.

Again, all worked ok, and to plan.

However, from time to time, code which has already been tested successfully,
starts generating the following SQL error, on Profile.Save().

"Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be closed. "

Bemused, I checked the web.config against SourceSafe to see if any changes
had snook in - which they hadn't.

My database seemed ok.

Then I spotted ASPNETDB in the App_Data folder. I hadn't created this
database - it seems to be have been created by Visual Studio itself.

Can anyone explain what this database is for?

My understanding is that it is used to store users/memberships in the event
that no other database is specified, but this is not so in my case.

The last time I had this problem a couple of days ago, I did various
combinations of deleting the ASPNETDB files, attempted tweaking Web.Config,
restarting Visual Studio .. in fact ANYTHING to try and get things working
again, in complete bemusement about what had changed. I don't know what
combination of things did the trick, but I eventually got the app running
again. Only to encounter the same problem a couple of days later.

Anyway, in short, can anyone give me any advice on how to get the ASPNETDB
database (and any of its dependencies) OUT of my solution, and force my OWN
database to be used to users/membership/etc.? ... And have it STAY THAT WAY?!!


ANY advice will be gratefully received!

JoeFusion
 
G

Guest

the aspnetdb dealie is because that's the default provider database defined
in machine.config. To override this you need to specifically add the <remove
name=...
semantics in the web.config. I don't have the exact syntax handy but that
should get you started on the right path. After you Clear or Remove the
default provider, then you can add your own custom provider connection string.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
K

Kevin Jones

The DB in App_Data is the database created by the default provider. The
connection string for this is called LocalSqlServer and is defined in
machine.config. Probably the easiest way to fix this is to remove this
definition and re-create it in your apps web.config. Something like:

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="[Your connection string here]"
providerName="System.Data.SqlClient" />
</connectionStrings>


Kevin
 

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

Top