ErocM
ErocM

Reputation: 4662

cannot get Item in NameValueCollection to be recognized

I am trying to set my config from code according to this post Changing .net Membership ConnectionString

In this post, it has this code:

public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
    // Get your new connnection string name and then overwrite the base here:
    config.Item["connectionStringName"] = "MyNewConnectionStringName";

    base.Initilize(name, config);
}

I made my class as such:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.Security;
using System.Collections.Specialized;

namespace WebUsers
{
  internal class MembershipOverride : SqlMembershipProvider
  {
    public override void Initialize(string name, NameValueCollection configx)
    {
      // Get your new connnection string name and then overwrite the base here:
      configx.Item["connectionStringName"] = "MyNewConnectionStringName";
      base.Initilize(name, config);
    }
  }
}

I cannot get Item or Initialize to be recognized.

It is doing this:

enter image description here

Anyone see what I am doing wrong?

Upvotes: 1

Views: 312

Answers (1)

AlexD
AlexD

Reputation: 32576

I cannot get Item or Initialize to be recognized.

There is a typo. You call base.Initilize instead of base.InitiAlize.

To access the collection element, try just

configx["connectionStringName"] = "MyNewConnectionStringName";

Upvotes: 2

Related Questions