locked
Membership with remote SQL database - Error. RRS feed

  • Question

  • User-1636962037 posted
    I'm trying to configure ASP.NET2 Membership/roles/profiles and so on, to use a remote MSSQL 2005 server. I ran the aspnet_regsql.exe and it created the tables succesfully.

    In my root web.config I got the following:

      <connectionStrings>
        <add name="webhotel" connectionString="Data Source=127.0.0.2; user id=XXX; password=XXX; Initial Catalog=XXX;"
             providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <roleManager enabled="true" />
        <compilation debug="false" />
        <authentication mode="Forms" />
        <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add
              name="SqlProvider"
              type="System.Web.Security.SqlMembershipProvider"
              connectionStringName="webhotel"
              applicationName="MyApplication"
              enablePasswordRetrieval="false"
              enablePasswordReset="true"
              requiresQuestionAndAnswer="true"
              requiresUniqueEmail="true"
              passwordFormat="Hashed" />
          </providers>
        </membership>
      </system.web>


    When I fire up the ASP.NET Configuration Manager and trying to create the first user, I get the following error:

    An error was encountered. Please return to the previous page and try again.

    The following message may help in diagnosing the problem: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    Any suggestions?
    Thanks in advance.

    Tommy Jakobsen
    Monday, April 3, 2006 4:52 AM

All replies

  • User-1007037156 posted

    Just to check, but did you provide the same Sql connection info to aspnet_regsql that you're specifying in your connection string?  I'm asking because if you did, this eliminates any remote connectivity issues plus it's good to know that we're still targeting the same database.

    I suspect the Sql Server targetd by the ASP.NET configuration tool isn't what you expect.  Can you double check the web.config for your site and see if it's still the same as what you've quoted in your post?

    Monday, April 3, 2006 3:35 PM
  • User-1636962037 posted

    Just to check, but did you provide the same Sql connection info to aspnet_regsql that you're specifying in your connection string?  I'm asking because if you did, this eliminates any remote connectivity issues plus it's good to know that we're still targeting the same database.

    I suspect the Sql Server targetd by the ASP.NET configuration tool isn't what you expect.  Can you double check the web.config for your site and see if it's still the same as what you've quoted in your post?



    It's exactly the same - I just checked :(
    Any ideas?
    Wednesday, April 5, 2006 11:55 AM
  • User-1007037156 posted

    Let's remove the ASP.NET configuration tool from the equation.

    Can you create a simple aspx page for your site which just calls "Membership.DeleteUser("foo");"? 

    If this doesn't work, then we know there's something wrong with the web.config used by your site or there's some configuration issue with the remote database.  If it does work, then there's likely an issue with the ASP.NET configuration tool.

    Friday, April 7, 2006 12:08 PM
  • User1332297693 posted
    Hi
    I have enocountered the same problem (I can say that the context is even stranger).
    Using the Asp.Net Configuration Tool I am able to create manage users (create/edit/delete), but when it comes to roles, I get a similar error:
    "The following message may help in diagnosing the problem: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"
    Also when connecting to the Security Tab it takes some time (and to SQL server is easily accesible from other applications). I have tried this for a few different applications, and got the same result.
    The section in web.config regarding authentication and membership looks like:

    <authentication mode="Forms">
          <forms name=".ASPXFORMSAUTH" />
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>
        <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear/>
            <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="aspnetdbConnectionString"
                 applicationName="TestItAll" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true"
              requiresUniqueEmail="true" passwordFormat="Hashed"/>
          </providers>
        </membership>

    The connectionString is the same with another app which is working fine.

    Best Regards
    Tudor Dumitriu
    Tuesday, August 8, 2006 3:26 PM
  • User1332297693 posted
    Hi again.
    I've found out (with some help - softer was nice to show me) that you should add also a provider for roles. Same goes for Providers.
    <roleManager enabled="true" defaultProvider="SqlRoleProvider">
          <providers>
            <clear/>
            <add name="SqlRoleProvider" applicationName="TestItAll" connectionStringName="aspnetdbConnectionString"
                 type="System.Web.Security.SqlRoleProvider"/>
          </providers>
    </roleManager>
    Hope that this will help.

    Tudor Dumitriu
    Wednesday, August 9, 2006 4:53 PM