C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » WCF »

How to set connection string at runtime in custom membership provider "Initialize" event


Posted Date: 21 Oct 2009      Posted By: deepak arora      Member Level: Bronze     Points: 1   Responses: 3



i tried to use below mentioned code but

"FieldInfo connectionStringField " line giving object reference error bcoz "GetType().BaseType.GetField(" returns null value. i need sample code which should work.
-----------------------------------------------

public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);

// Update the private connection string field in the base class. string connectionString = "my new connection string value that I get from a custom decryption class not shown here"
// Set private property of Membership provider.
FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
connectionStringField.SetValue(this, connectionString);
}





Responses

Author: Lalji    21 Oct 2009Member Level: DiamondRating: 1 out of 5     Points: 1

you will get your solution from this link

http://www.williablog.net/williablog/post/2008/05/02/Setting-Membership-Profile-Role-providers-connection-string-at-runtime.aspx



Author: deepak arora    21 Oct 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

i do not want to change name of connection string. i want to change value of connection string e.g connectionString="Data Source=.....


Author: Siva    21 Oct 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Hi Deepak,

You can refer below mentioned URL. It's working fine.

http://forums.asp.net/p/997608/2862586.aspx



Post Reply
You must Sign In to post a response.
Next : How to set connection string at runtime in custom membership provider
Previous : How to implement GetPropertyValues and SetPropertyValues in WCF.
Return to Discussion Forum
Post New Message
Category: WCF

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use