Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more passwords + update samples #2929

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@
try
{
string connectString =
"Data Source=(local);User ID=ab;Password=MyPassword;" +
"Data Source=(local);Integrated Security=SSPI" +
"Initial Catalog=AdventureWorks";

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
Expand Down Expand Up @@ -1477,34 +1477,33 @@
</note>
<!-- SqlConnectionStringBuilder_Remove -->
<code language="c#">
using System;
using System.Data;
using Microsoft.Data.SqlClient;

class Program
{
static void Main()
{
try
{
string connectString =
"Data Source=(local);User ID=ab;Password= a1Pass@@11;" +
"Initial Catalog=AdventureWorks";

"Data Source=(local);User ID=ab;";

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
Console.WriteLine("Original: " + builder.ConnectionString);

// Use the Remove method
// in order to reset the user ID and password back to their
// default (empty string) values.
// in order to reset the user ID back to its
// default (empty string) value.
builder.Remove("User ID");
builder.Remove("Password");


// Turn on integrated security:
builder.IntegratedSecurity = true;


// Turn off encryption for local db
builder.Encrypt = false;

Console.WriteLine("Modified: " + builder.ConnectionString);

using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
{
connection.Open();
Expand All @@ -1516,7 +1515,7 @@
{
Console.WriteLine(ex.Message);
}

Console.WriteLine("Press any key to finish.");
Console.ReadLine();
}
Expand All @@ -1526,8 +1525,9 @@
The example displays the following text in the console window:
</para>
<code>
Original: Data Source=(local);Initial Catalog=AdventureWorks;User ID=ab;Password= a1Pass@@11
Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True Database=AdventureWorks
Original: Data Source=(local);User ID=ab;
Modified: Data Source=(local);Integrated Security=True; Encrypt=false
Database = master
</code>
</example>
<exception cref="T:System.ArgumentNullException">
Expand Down