title: Setting Membership provider's database at runtime...?
body: <p>We're using ASP.Net membership providers (the SQL Server provider), and I want to be able to change only the database name in the class . To do this, I need the ASP.Net membership provider configured so that my installer can use it </p>
  
  <p>i used code as</p>
  
  <pre><code>public class CodeFirstMembershipProvider : SqlMembershipProvider
      {    
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)  
        { 
            base.Initialize(name, config);  
  
            // hard coded for testing  
            string connectionString = @"server=localhost;database=masterdb;uid=master;pwd=password";
  
            // Set private property of Membership provider.  
            FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);  
            if(connectionStringField != null)
              connectionStringField.SetValue(this, connectionString);  
        }
  }
  </code></pre>
  
  <p>in above code i need to enter and change the full connection string values..</p>
  
  <p>it too works fine .....</p>
  
  <p>but my query is to change only the database name only of the current connection string mentioned in web.config file..</p>
  
  <p>So is there a way to switch the databse name through an ASP.Net membership through code ?</p>