VS C# Sql Client unable to connect to SQL Server, uses Windows auth instead of SQL Server auth

236 views Asked by At

I have two desktop clients with VS 2017. I inherited a C# .NET app that connects to a SQL Server in the next room. We generally use SQL Server authentication (as opposed to Windows authentication) when we perform SQL queries.

I use a connection string that looks something like this ...

"Data Source=DR101; User Id = DR_DATA; Password = CD7504st; Integrated Security=SSPI; TransparentNetworkIPResolution=False"

... which works like a charm from the first desktop. From the second desktop it always fails to access the database, giving an error indicating a Windows login failure ...

... threw an exception.
System.Data.SqlClient.SqlException: Login failed for user 'SDAR\SdarAutoSvc'

I have compared everything I can think of between these two systems. As far as I can ascertain, they are identical in most every way ... both use the same Visual Studio (Help > About, and compared the long list of module versions. Identical on both systems), the same System.Data.dll module, the same App.config, C# source code, input data, etc.

The failing system only fails via this visual studio app - i.e., I can reach the database server from that desktop via SMSS, using the SQL Server credentials (not Windows authentication).

I am out of ideas as to how this second machine might be unable to access the database, and why it apparently uses Windows auth rather than the sql userId/password from the connection string.

1

There are 1 answers

0
Mukesh Arora On

If you want SQL server Authentication then remove Integrated Security=SSPI; from the connection string.

Try with this connection string -

 "Data Source=DR101; User Id = DR_DATA; Password = CD7504st; TransparentNetworkIPResolution=False"