Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:59:03+00:00 2026-05-28T03:59:03+00:00

I started to write project on asp.net and faced with trouble. When I try

  • 0

I started to write project on asp.net and faced with trouble. When I try to execute this code:

System.Web.Security.Roles.CreateRole("User");

I get an exception:
An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax.
Parameter name: connectionString

That’s part of the configuration of my project:

<configuration>
    <system.web>
      ...
      <roleManager enabled="true" defaultProvider="SqlRoleProvider">
        <providers>
          <clear/>
          <add name="SqlRoleProvider"
               connectionString="ForumDB"
               applicationName="/"
               type="System.Web.Security.SqlRoleProvider"/>
        </providers>
      </roleManager>
    </system.web>
  <connectionStrings>
    <clear/>
    <add name="ForumDB"
         connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=ForumDB;Integrated Security=True;Pooling=False"
         providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

I initially thought that the connection string has been written wrong, but I checked several times. Also this code works:

    var connectionString = ConfigurationManager.ConnectionStrings["ForumDB"];
    DbProviderFactory providerFactory = DbProviderFactories.GetFactory(connectionString.ProviderName);
    DbConnection connection = providerFactory.CreateConnection();
    connection.ConnectionString = connectionString.ConnectionString;
    connection.Open();

I am sure that the connection string has been written correctly. What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:59:04+00:00Added an answer on May 28, 2026 at 3:59 am

    I made a mistake here:

    <roleManager enabled="true" defaultProvider="SqlRoleProvider">
        <providers>
            <clear/>
                <add name="SqlRoleProvider"
                    connectionString="ForumDB"
                    applicationName="/"
                    type="System.Web.Security.SqlRoleProvider"/>
        </providers>
    </roleManager>
    

    I had to write:

    connectionStringName="ForumDB"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started a new project, and now with ASP.NET MVC being designed in
I started a new project this afternoon and now that I've decided to write
I currently write quite a bit of code in ASP.NET MVC and use jQuery
Today I finally started to write some unit tests for my new ASP.net MVC
I just started with a project that requires me to write to PDF file.
I'm an avid vim user and have started to write some SQL code recently.
Question simple and quick: I have started to use Netbeans to write some code
I'm using asp.NET MVC 2 for my current project and I need to validate
I've recently started a new web development project for an embedded device and wanted
How to efficiently write code and debug windows service project in visual studio? Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.