Sunday, May 1, 2011

How to connect to DB on SERVER for Asp.Net membership?

I've just upload my ASPNETDB.mdf using "Generate Scripts" into server. The problem is, I don't know how can I connect to it for my Membership.(e.g LogIn Controls) where is the ConnectionString?

From stackoverflow
  • The connectionstring is in the web.config file.

  • Modify the web.config file for your application to redefine the LocalSqlServer connection string to point to the database.

    <connectionStrings>
      <remove name="LocalSqlServer"/>
      <add name="LocalSqlServer"
           connectionString="server=.;database=aspnetdb;
           integrated security=sspi;"/>   
    </connectionStrings>
    

    If your Membership provider is not pointing to "LocalSqlServer", then you can modify that in the web.config as well.

    <membership>
      <providers>
        <remove name="AspNetSqlMembershipProvider"/>
        <add name="AspNetSqlMembershipProvider"
          type="System.Web.Security.SqlMembershipProvider, ..."
          connectionStringName="LocalSqlServer"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          applicationName="/"
          requiresUniqueEmail="false"
          passwordFormat="Hashed"
          maxInvalidPasswordAttempts="5"
          minRequiredPasswordLength="7"
          minRequiredNonalphanumericCharacters="1"
          passwordAttemptWindow="10"
          passwordStrengthRegularExpression=""
        />
      </providers>
    </membership>
    
  • update the Data Source tag in web config

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<<PATH Goes Here>>;Persist Security Info=False;
    

0 comments:

Post a Comment