SQL Connection Error on Profile.Save()

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9lRnVzaW9u?=, Aug 22, 2006.

  1. 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
    =?Utf-8?B?Sm9lRnVzaW9u?=, Aug 22, 2006
    #1
    1. Advertising

  2. 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




    "JoeFusion" wrote:

    > 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
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Aug 22, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?Sm9lRnVzaW9u?=

    Kevin Jones Guest

    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
    Kevin Jones, Aug 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad
    Replies:
    1
    Views:
    1,123
    Roedy Green
    Jul 19, 2005
  2. shapper
    Replies:
    1
    Views:
    431
    Juan T. Llibre
    Sep 17, 2006
  3. Andy B
    Replies:
    0
    Views:
    508
    Andy B
    May 3, 2008
  4. milop

    Profile.Save()

    milop, May 23, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    409
    milop
    May 23, 2008
  5. Steven
    Replies:
    5
    Views:
    467
    Steven
    Oct 24, 2008
Loading...

Share This Page