title: Error in VBA Connection String
body: <p>I am facing issues with connecting to a SQL Server database from Excel VBA. I primarily suspect that the error is occurring because of the incorrect handling of the password containing double quotes.</p>
  <p>Scenario :</p>
  <ul>
  <li>SQL Server Name - FOO\BAR</li>
  <li>Initial Catalog - ScrollBar</li>
  <li>User - Test_User</li>
  <li>Password - tejg3kl!&quot;</li>
  </ul>
  <p>The connection string I am using is:</p>
  <pre><code>Public Const ConnectionStringONLINE = &quot;Provider=SQLOLEDB.1;Data Source=FOO\BAR;Initial Catalog=ScrollBar;User Id=Test_User;Password=tejg3kl!&quot;&quot;;&quot;
  </code></pre>
  <p>An extra double quote is included in the Password value as an escape sequence character.</p>
  <p>Code to connect to the database -</p>
  <pre><code>Dim DbConn As ADODB.Connection
  Set DbConn = New ADODB.Connection  
  DbConn.Open ConnectionStringONLINE
  </code></pre>
  <p>When the above code is executed, I receive an error -</p>
  <blockquote>
  <p>Run-time error'-2147217843 (80040e4d)':</p>
  <p>Login failed for user 'Test_User'.</p>
  </blockquote>
  <p>I did an UDL test for the same credentials specified in the connection string and the connection worked fine.</p>
  <p>Any suggestions on why the error is occurring in VBA? Do I need to modify the connection string?</p>
  <p>Edit - Just changed the password string to include an exclamation mark before the double quotes to make it appear exactly like the real password that I am using.</p>