Note that there are some explanatory texts on larger screens.

plurals
  1. POConnection string works for OLE DB connection but not Sql Server Native Client 10.0
    primarykey
    data
    text
    <p>The following is a connection string generated when I connect to a database using a configuration tool with Microsoft OLE DB Provider for SQL Server.</p> <pre><code>Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=sa; Initial Catalog=database;Data Source=localhost;Use Procedure for Prepare=1; Auto Translate=True;Packet Size=4096;Workstation ID=computer1; Use Encryption for Data=False;Tag with column collation when possible=False </code></pre> <p>If I connect to the same database but with SQL Server Native Client 10.0 I get this connection string.</p> <pre><code>Provider=SQLNCLI10.1;Integrated Security=\"\";Persist Security Info=False; User ID=sa;Initial Catalog=database;Data Source=localhost;Use Procedure for Prepare=1; Auto Translate=True;Packet Size=4096;Workstation ID=computer1; Initial File Name=\"\";Use Encryption for Data=False; Tag with column collation when possible=False; MARS Connection=False;DataTypeCompatibility=0;Trust Server Certificate=False\0 </code></pre> <p>I have a c# application that reads either one of these connection strings and uses it to create a connection to my database like so</p> <pre><code>SqlConnectionStringBuilder _sqlConnectionStringBuilder = new SqlConnectionStringBuilder(); OleDbConnectionStringBuilder conBuilder = new OleDbConnectionStringBuilder( CONNECTION STRING SHOWN ABOVE); _initialCatalogValue = (string)conBuilder["Initial Catalog"]; _dataSourceValue = conBuilder.DataSource; _sqlConnectionStringBuilder.Password = (string)conBuilder["Password"]; _sqlConnectionStringBuilder.UserID = (string)conBuilder["User Id"]; _sqlConnectionStringBuilder.InitialCatalog = _initialCatalogValue; _sqlConnectionStringBuilder.DataSource = _dataSourceValue; _sqlConnectionStringBuilder.PersistSecurityInfo = true; _conn = new SqlConnection(_sqlConnectionStringBuilder.ConnectionString); _conn.Open(); </code></pre> <p>The problem that when I use the SQL Server native client the password is empty and my SQLConnection will fail on the login. The error I get is "Login failed for user 'sa'".</p> <p>The OLE DB connection string is successful. Is my login failing for the sql server native client due to some of the classes I am using in c#? Does the Sql Server Native Client 10.0 encrypt the password? Should I try to identify which provider is in the connection string and have two different code paths? If so what would it take to connect?</p> <p>Basic question is, how can I ensure a successful connection regardless of which connection string I receive (only the two above)?</p> <p>N.B. I have no control over the connection strings. I can only work with what I am receiving.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload