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 922439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:01:51+00:00 2026-05-15T19:01:51+00:00

I have a connection string in my web config: <add name=MyConString connectionString=Server=dbsrv;User ID=myDbUser;Password=somepassword providerName=System.Data.SqlClient

  • 0

I have a connection string in my web config:

<add name="MyConString" connectionString="Server=dbsrv;User ID=myDbUser;Password=somepass"word" providerName="System.Data.SqlClient" />

As you see, there is a quotation sign ( ” ) in the password (given from other dept. I can’t change this db users password).

How do I have to escape the quote in this connection string?

Btw: I already tried & quot; in the string. That didn’t work – ado.net got an ArgumenException then: “Format of the initialization string does not conform to specification starting at index 57.”
57 is where the & quot; is in my connection string.
I also tried enclosing the password part in ‘ – didn’t work either.

Also tried “” and \” – web.config can’t be parsed then.

Thanks for the solution:

I had to combine the escaping of the double quote and putting the password in single quotes:

<add name="MyConString" connectionString="Server=dbsrv;User ID=myDbUser;Password='somepass&quot;word'" providerName="System.Data.SqlClient" />
  • 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-15T19:01:51+00:00Added an answer on May 15, 2026 at 7:01 pm

    Use &quot; instead of " to escape it.

    web.config is an XML file so you should use XML escaping.

    connectionString="Server=dbsrv;User ID=myDbUser;Password=somepass&quot;word"
    

    See this forum thread.

    Update:

    &quot; should work, but as it doesn’t, have you tried some of the other string escape sequences for .NET? \" and ""?

    Update 2:

    Try single quotes for the connectionString:

    connectionString='Server=dbsrv;User ID=myDbUser;Password=somepass"word'
    

    Or:

    connectionString='Server=dbsrv;User ID=myDbUser;Password=somepass&quot;word'
    

    Update 3:

    From MSDN (SqlConnection.ConnectionString Property):

    To include values that contain a semicolon, single-quote character, or double-quote character, the value must be enclosed in double quotation marks. If the value contains both a semicolon and a double-quote character, the value can be enclosed in single quotation marks.

    So:

    connectionString="Server=dbsrv;User ID=myDbUser;Password='somepass&quot;word'"
    

    The issue is not with web.config, but the format of the connection string. In a connection string, if you have a " in a value (of the key-value pair), you need to enclose the value in '. So, while Password=somepass"word does not work, Password='somepass"word' does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use defauldict, like this: >>> import collections >>>… May 16, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer case input when "quit", "exit" break end May 16, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer Check this Dim ids = {1, 2, 3} Dim query… May 16, 2026 at 5:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following script that will update the connection string across three different
I have two ASP.NET websites on a web-server, and two SQL Server databases. I
Currently my web.config has this: <appSettings> <add key=UserName /> <add key=DBServer /> <add key=DBUserName
I have just joined a project that has a connection string which is defined
I have a project in which I'm accessing a MySql database on my web
I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I
I have two exactly the same web sites hosted in two different machines under
I see several others have posted this question, however, none of the solutions I've
I develop an asp.net web application and I use ASP.NET membership provider. The application
How do you construct a DbConnection based on a provider name ? Sample provider

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.