Skip to content

Commit a947223

Browse files
Remove more passwords + update samples (#2929)
1 parent 641892c commit a947223

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@
925925
try
926926
{
927927
string connectString =
928-
"Data Source=(local);User ID=ab;Password=MyPassword;" +
928+
"Data Source=(local);Integrated Security=SSPI" +
929929
"Initial Catalog=AdventureWorks";
930930

931931
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
@@ -1477,34 +1477,33 @@
14771477
</note>
14781478
<!-- SqlConnectionStringBuilder_Remove -->
14791479
<code language="c#">
1480-
using System;
1481-
using System.Data;
14821480
using Microsoft.Data.SqlClient;
1483-
1481+
14841482
class Program
14851483
{
14861484
static void Main()
14871485
{
14881486
try
14891487
{
14901488
string connectString =
1491-
"Data Source=(local);User ID=ab;Password= a1Pass@@11;" +
1492-
"Initial Catalog=AdventureWorks";
1493-
1489+
"Data Source=(local);User ID=ab;";
1490+
14941491
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
14951492
Console.WriteLine("Original: " + builder.ConnectionString);
1496-
1493+
14971494
// Use the Remove method
1498-
// in order to reset the user ID and password back to their
1499-
// default (empty string) values.
1495+
// in order to reset the user ID back to its
1496+
// default (empty string) value.
15001497
builder.Remove("User ID");
1501-
builder.Remove("Password");
1502-
1498+
15031499
// Turn on integrated security:
15041500
builder.IntegratedSecurity = true;
1505-
1501+
1502+
// Turn off encryption for local db
1503+
builder.Encrypt = false;
1504+
15061505
Console.WriteLine("Modified: " + builder.ConnectionString);
1507-
1506+
15081507
using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
15091508
{
15101509
connection.Open();
@@ -1516,7 +1515,7 @@
15161515
{
15171516
Console.WriteLine(ex.Message);
15181517
}
1519-
1518+
15201519
Console.WriteLine("Press any key to finish.");
15211520
Console.ReadLine();
15221521
}
@@ -1526,8 +1525,9 @@
15261525
The example displays the following text in the console window:
15271526
</para>
15281527
<code>
1529-
Original: Data Source=(local);Initial Catalog=AdventureWorks;User ID=ab;Password= a1Pass@@11
1530-
Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True Database=AdventureWorks
1528+
Original: Data Source=(local);User ID=ab;
1529+
Modified: Data Source=(local);Integrated Security=True; Encrypt=false
1530+
Database = master
15311531
</code>
15321532
</example>
15331533
<exception cref="T:System.ArgumentNullException">

0 commit comments

Comments
 (0)