Iam new to asp.net membership &我需要幫助以編程方式更改其連接字符串。更改成員資格連接字符串
我已經試過到目前爲止是
我創建了一個類項目名稱,樣品名稱空間**,並延長了System.Web.Security.SqlMembershipProvider
代碼
namespace Sample
{
public class Connectionstring : SqlMembershipProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
string connectionString = "server=xx.xx.xx;database=db;user id=un;password=pwd";
// Set private property of Membership provider.
FieldInfo connectionStringField = GetType().BaseType
.GetField("_sqlConnectionString", BindingFlags.Instance |
BindingFlags.NonPublic);
connectionStringField.SetValue(this, connectionString);
}
}
}
和改變網絡配置文件會員標記爲
<membership defaultProvider="SQLMembershipProvider">
<providers>
<add name="SQLMembershipProvider" type="sample.Connectionstring,sample" connectionStringName="SQLMembershipConnString" applicationName="@@@@@@@" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" />
</providers>
</membership>
and while r統一web應用程序項目我改變的連接字符串不會被改變?
等待您寶貴的答覆和意見
出於好奇,你爲什麼需要這樣做? – Alyce 2013-03-07 07:40:06
@Alyce我的工作是爲該表創建用戶並根據用戶輸入數據庫內的數據庫運行命令 – GowthamanSS 2013-03-07 07:46:54
嗨,試試這個鏈接可能對你有幫助http://forums.asp.net/t/997608。aspx/1/10 – Niventh 2013-03-07 07:57:21