Last post Jun 11, 2014 05:07 PM by PatriceSc
Jun 11, 2014 03:17 PM|X-treme|LINK
Can someone guide me when to use the trusted_connection=false; in the connection string.
Jun 11, 2014 03:22 PM|AidyF|LINK
Trusted connection means if you're using integrated security or not (you can use the integrated security property in stead. Trusted connection (or integrated security on) means the connection will be made using the Windows account the code is currently
running under. Trusted connection false means you will be supplying your own user id and password that the connection will use, and that will then use SQL Server security rather than Windows integrated security.
Jun 11, 2014 03:28 PM|dougvdotcom|LINK
A trusted connection is used if you're connecting to the database without providing a user name and password.
For example, if you are connecting via a Data Source Name, and the DSN contains the user ID you're using to connect, then your trusted connection is true.
If you are providing a user name and password as part of your connection string, then trusted connection is false.
If you specify a trusted connection in your connection string, whatever user name and password you pass to the database server will be ignored. In that case, your SQL Server needs to be configured to allow for trusted connections, which means either using
the sa account in SQL Server or using Windows Authentication to connect to the server.
So, it's a trusted connection if:
Otherwise, it's not trusted.
Jun 11, 2014 04:19 PM|X-treme|LINK
Thanks for the replies. I am trying to pass Uid/Pwd explicitly so i have declared trusted_connection = false; Is it necessary to place the trusted_connection = false or i can remove the property from the connection string.
Jun 11, 2014 05:04 PM|dougvdotcom|LINK
You should add it, but in most connnection strings, if you omit a trusted connection value, the default is that it is not a trusted connection/
Jun 11, 2014 05:07 PM|PatriceSc|LINK
Yes, false is the default value so this is not needed and you can remove that from your connection string. It could have been quicker to just try rather than to ask in a forum ;-)
For further reference keep also the SqlConnection.ConnectionString documentation at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx handy.
It includes a description of most if not all SQL Server connection string keywords.
If "trying" means that you have a problem wiht your connection string, just directly post the error message you have.