darkdante
darkdante

Reputation: 707

C# - How to get TrustedConnection property from a SqlConnection

I want to get connection string components from a string containing the conn string.

It is pretty simple to get Database, Sql Instance , Username and Password using a SqlConnectionStringBuilder, like this:

SqlConnectionStringBuilder cb = new SqlConnectionStringBuilder(cString);
this.textBoxUsername.Text = this.UserName = cb.UserID;
this.textBoxPassword.Text = this.Password = cb.Password;
...

My problem is that i want to get the TrustedConnection also, and i don't know how to do it.

Having the conn string "Server=Me\SQLEXPRESS;Database=AWEBL; Connection Timeout = 30;" Trusted_Connection=True;" , is it any other way than parsing the cString (connection string) to get the Trusted_Connection property ?

Thank you!

Upvotes: 1

Views: 455

Answers (1)

Chris Wijaya
Chris Wijaya

Reputation: 1306

set:

cb["Trusted_Connection"] = true;

get:

var trustedConnection = cb["Trusted_Connection"];

Upvotes: 4

Related Questions