1

The IT changed the SQL Server to a new Microsoft SQL Server 2017, and some apps stopped working. These apps (C#) use a connection string like this:

SqlConnection conn = new SqlConnection("Data Source=192.168.100.101;Initial Catalog=Warehouse;Persist Security Info=True;User ID=****;Password=******");

But the new server works with Windows authentication. I'd like to know how to change the authentication for the new SQL Server to make apps work again.

Thanks guys.

2
  • 2
    Check connectionstrings.com or simply remove the User ID and Password keys and Add Trusted_Connection=Yes Commented Jan 18, 2019 at 21:59
  • I tried this string, but still cannot connect to DB. Is there a way to change the authentication type from Windows Authentication to sort of network authentication, just as it was before with a username and password? Commented Jan 18, 2019 at 22:38

1 Answer 1

1

In that case you can use the Integrated Security options, so the windows account that is running your C# program will be used

SqlConnection conn = new SqlConnection("Data Source=192.168.100.101;Initial Catalog=Warehouse;Integrated Security=True");

More info here https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.7.2

Sign up to request clarification or add additional context in comments.

2 Comments

What if it's multiple users? Should all users have access to the SQL Server? What if the database has a specific login account that it uses?
I tried this string but still cannot connect to DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.