Change credentials or write the good connection string to a SQL Server database
I am writing some test.
I want to connect to a database on a server and I use Visual Studio 2015 Community edition learning c#.
Following this guide: https://msdn.microsoft.com/en-us/library/hh272693%28v=vs.103%29.aspx
I open SQL Server object explorer and get to the server. But I notice that the connection is made with my actual credentials.
And so the connection string is:
Data Source=serverwiththedatabase;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;
I want to use domain\domainuser and password and just perform a select.
So should I change it in:
The most important values in an connection string for an SqlConnection are:
- Data Source: this is your database server name (not server!)
- Initial catalog: this is your database name (not database!)
- Integrated Security: True if you want to use windows authentication, False if you want SQL server authentication
AFAIK there are only these two options: windows or sql server. So if you set Integrated Security to False, you need to specify UIDand PWD, which will be the credentials for a SQL server authentication. This user has to be defined in the SQL server's user management and has nothing to do with domain users.
If you use windows authentication, the connection is started with the user credentials of the calling process (which in your case will be your windows user credentials).