title: Change the SqlConnection,Credentials property
body: <p>So i have a login page and i have to implement a validation: 'If the user is "sa" then it should connect to the Database using that users credentials', which means i have to modify the credentials of my <code>SqlConnection</code> object:</p>
  
  <pre><code>        if(username.Equals("sa", StringComparison.OrdinalIgnoreCase))
          {
              var securePassword = new System.Security.SecureString();
              foreach(char character in password)
              {
                  securePassword.AppendChar(character);
              }
  
              securePassword.MakeReadOnly();
              var credentials = new SqlCredential(username, securePassword);
              sqlConn.Close();
              sqlConn.Credential = credentials;
  
              sqlConn.Open();
  
              return true;
          }
  </code></pre>
  
  <p>But im getting an exception in <code>sqlConn.Credential = credentials;</code> even though the property is not <code>readonly</code></p>
  
  <blockquote>
    <p>InvalidOperationException: Cannot use Credential with UserID, UID, Password, or PWD connection string keywords.</p>
  </blockquote>
  
  <p>Is there any other way to change the <code>Credentials</code> property?</p>
  
  <p>Thanks in advance.</p>