diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/CS/source.cs
deleted file mode 100644
index cbe4508e997..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/CS/source.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Data;
-using System.Data.Common;
-
-class Program
-{
- //
- static void Main()
- {
- DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
- builder.ConnectionString =
- "Provider=MSDataShape.1;Persist Security Info=false;" +
- "Data Provider=MSDAORA;Data Source=orac;" +
- "user id=username;password=*******";
-
- foreach (string value in builder.Values)
- Console.WriteLine(value);
- }
- //
-}
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/CS/source.cs
deleted file mode 100644
index 928a2bf1322..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/CS/source.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.Odbc;
-
-class Program
-{
- static void Main()
- {
- try
- {
- // Build an empty instance, just to see
- // the contents of the keys.
- DumpBuilderContents("");
-
- // Create a SQL Server connection string.
- DumpBuilderContents("Driver={SQL Server};Server=(local);Database=AdventureWorks;Uid=ab;Pwd=pass@word1");
-
- // Create an Access connection string.
- DumpBuilderContents(@"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\info.mdb;Exclusive=1;Uid=admin;Pwd=pass@word1");
-
- // Create an Oracle connection string.
- DumpBuilderContents("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Admin;Pwd=pass@word1;");
-
- // Create a Sybase connection string.
- DumpBuilderContents("Driver={SYBASE ASE ODBC Driver};Srvr=SomeServer;Uid=admin;Pwd=pass@word1");
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.ArgumentException ex)
- {
- Console.WriteLine("Error: " + ex.Message);
- }
- }
-
- private static void DumpBuilderContents(string connectString)
- {
- OdbcConnectionStringBuilder builder =
- new OdbcConnectionStringBuilder(connectString);
- Console.WriteLine("=================");
- Console.WriteLine("Original connectString = " + connectString);
- Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- {
- Console.WriteLine(key + "=" + builder[key].ToString());
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/CS/source.cs
deleted file mode 100644
index 928a2bf1322..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/CS/source.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.Odbc;
-
-class Program
-{
- static void Main()
- {
- try
- {
- // Build an empty instance, just to see
- // the contents of the keys.
- DumpBuilderContents("");
-
- // Create a SQL Server connection string.
- DumpBuilderContents("Driver={SQL Server};Server=(local);Database=AdventureWorks;Uid=ab;Pwd=pass@word1");
-
- // Create an Access connection string.
- DumpBuilderContents(@"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\info.mdb;Exclusive=1;Uid=admin;Pwd=pass@word1");
-
- // Create an Oracle connection string.
- DumpBuilderContents("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Admin;Pwd=pass@word1;");
-
- // Create a Sybase connection string.
- DumpBuilderContents("Driver={SYBASE ASE ODBC Driver};Srvr=SomeServer;Uid=admin;Pwd=pass@word1");
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.ArgumentException ex)
- {
- Console.WriteLine("Error: " + ex.Message);
- }
- }
-
- private static void DumpBuilderContents(string connectString)
- {
- OdbcConnectionStringBuilder builder =
- new OdbcConnectionStringBuilder(connectString);
- Console.WriteLine("=================");
- Console.WriteLine("Original connectString = " + connectString);
- Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- {
- Console.WriteLine(key + "=" + builder[key].ToString());
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/Project.csproj
new file mode 100644
index 00000000000..283a2efeb88
--- /dev/null
+++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/Project.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Library
+ net8
+
+
+
+
+
+
+
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs
index c8dcfa1233a..01a42cd4415 100644
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs
+++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs
@@ -1,5 +1,4 @@
using System;
-using System.Data;
//
using System.Data.Odbc;
@@ -7,15 +6,14 @@ class Program
{
static void Main()
{
- OdbcConnectionStringBuilder builder =
- new OdbcConnectionStringBuilder();
- builder.Driver = "Microsoft Access Driver (*.mdb)";
+ OdbcConnectionStringBuilder builder = new()
+ {
+ Driver = "Microsoft Access Driver (*.mdb)"
+ };
// Call the Add method to explicitly add key/value
// pairs to the internal collection.
builder.Add("Dbq", "C:\\info.mdb");
- builder.Add("Uid", "Admin");
- builder.Add("Pwd", "pass!word1");
Console.WriteLine(builder.ConnectionString);
Console.WriteLine();
@@ -30,16 +28,11 @@ static void Main()
builder.ConnectionString =
"driver={IBM DB2 ODBC DRIVER};Database=SampleDB;" +
"hostname=SampleServerName;port=SamplePortNum;" +
- "protocol=TCPIP;uid=Admin;pwd=pass!word1";
+ "protocol=TCPIP";
- Console.WriteLine("protocol = "
- + builder["protocol"].ToString());
+ Console.WriteLine($"protocol = {builder["protocol"].ToString()}");
Console.WriteLine();
- // Modify existing items.
- builder["uid"] = "NewUser";
- builder["pwd"] = "Pass@word2";
-
// Call the Remove method to remove items from
// the collection of key/value pairs.
builder.Remove("port");
@@ -54,9 +47,6 @@ static void Main()
// necessary.
builder["NewKey"] = "newValue";
Console.WriteLine(builder.ConnectionString);
-
- Console.WriteLine("Press Enter to finish.");
- Console.ReadLine();
}
}
//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/CS/source.cs
deleted file mode 100644
index 67d5890a798..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/CS/source.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.OleDb;
-
-class Program
-{
- static void Main()
- {
- try
- {
- // Build an empty instance, just to see
- // the contents of the keys.
- DumpBuilderContents("");
-
- // Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" +
- "Initial Catalog=AdventureWorks;" +
- "User Id=ab;Password=Password@1");
-
- // Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" +
- @"Data Source=C:\Sample.mdb");
-
- // Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" +
- "User Id=userName;Password=Pass@word1;");
-
- // Create an Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA");
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.ArgumentException ex)
- {
-
- Console.WriteLine("Error: " + ex.Message);
- }
- }
-
- private static void DumpBuilderContents(string connectString)
- {
- OleDbConnectionStringBuilder builder =
- new OleDbConnectionStringBuilder(connectString);
- Console.WriteLine("=================");
- Console.WriteLine("Original connectString = " + connectString);
- Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- {
- Console.WriteLine(key + "=" + builder[key].ToString());
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/CS/source.cs
deleted file mode 100644
index 290d7f0d8e5..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/CS/source.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.OleDb;
-
-class Program
-{
- static void Main()
- {
- try
- {
- // Build an empty instance, just to see
- // the contents of the keys.
- DumpBuilderContents("");
-
- // Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" +
- "Initial Catalog=AdventureWorks;" +
- "User Id=ab;Password=Password@1");
-
- // Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" +
- @"Data Source=C:\Sample.mdb");
-
- // Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" +
- "User Id=userName;Password=Pass@word1;");
-
- // Create a Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA");
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.ArgumentException ex)
- {
-
- Console.WriteLine("Error: " + ex.Message);
- }
- }
-
- private static void DumpBuilderContents(string connectString)
- {
- OleDbConnectionStringBuilder builder =
- new OleDbConnectionStringBuilder(connectString);
- Console.WriteLine("=================");
- Console.WriteLine("Original connectString = " + connectString);
- Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- {
- Console.WriteLine(key + "=" + builder[key].ToString());
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/CS/source.cs
deleted file mode 100644
index 290d7f0d8e5..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/CS/source.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.OleDb;
-
-class Program
-{
- static void Main()
- {
- try
- {
- // Build an empty instance, just to see
- // the contents of the keys.
- DumpBuilderContents("");
-
- // Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" +
- "Initial Catalog=AdventureWorks;" +
- "User Id=ab;Password=Password@1");
-
- // Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" +
- @"Data Source=C:\Sample.mdb");
-
- // Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" +
- "User Id=userName;Password=Pass@word1;");
-
- // Create a Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA");
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.ArgumentException ex)
- {
-
- Console.WriteLine("Error: " + ex.Message);
- }
- }
-
- private static void DumpBuilderContents(string connectString)
- {
- OleDbConnectionStringBuilder builder =
- new OleDbConnectionStringBuilder(connectString);
- Console.WriteLine("=================");
- Console.WriteLine("Original connectString = " + connectString);
- Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- {
- Console.WriteLine(key + "=" + builder[key].ToString());
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/CS/source.cs
deleted file mode 100644
index 5838d92cb3e..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/CS/source.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Data;
-//
-// You may need to set a reference to the System.Data.OracleClient
-// assembly before you can run this sample.
-using System.Data.OracleClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString = "Server=OracleDemo;UID=Mary;Pwd=*****";
- Console.WriteLine("Original: " + connectString);
- OracleConnectionStringBuilder builder =
- new OracleConnectionStringBuilder(connectString);
- Console.WriteLine("Modified: " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- Console.WriteLine(key + "=" + builder[key].ToString());
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.Collections.Generic.KeyNotFoundException ex)
- {
- Console.WriteLine("KeyNotFoundException: " + ex.Message);
- }
- catch (System.FormatException ex)
- {
- Console.WriteLine("Format exception: " + ex.Message);
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/CS/source.cs
deleted file mode 100644
index 2dd247958bc..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/CS/source.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Data;
-//
-// You may need to set a reference to the System.Data.OracleClient
-// assembly before you can run this sample.
-using System.Data.OracleClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString =
- "Data Source=OracleSample;User ID=Mary;Password=*****;";
-
- OracleConnectionStringBuilder builder =
- new OracleConnectionStringBuilder(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. Simply setting the
- // associated property values to an empty string will not
- // remove them from the connection string; you must
- // call the Remove method.
- builder.Remove("User ID");
- builder.Remove("Password");
-
- // Turn on integrated security.
- builder.IntegratedSecurity = true;
-
- Console.WriteLine("Modified: " + builder.ConnectionString);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/CS/source.cs
deleted file mode 100644
index a01cdf4c83d..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/CS/source.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Data;
-//
-// You may need to set a reference to the System.Data.OracleClient
-// assembly before you can run this sample.
-using System.Data.OracleClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString =
- "Data Source=OracleDemo;User ID=Mary;Password=*****";
-
- OracleConnectionStringBuilder builder = new OracleConnectionStringBuilder(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.
- builder.Remove("User ID");
- builder.Remove("Password");
-
- // Turn on integrated security.
- builder.IntegratedSecurity = true;
-
- Console.WriteLine("Modified: " + builder.ConnectionString);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/CS/source.cs
deleted file mode 100644
index e7ce1c0ea2f..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/CS/source.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Data;
-//
-// You may need to set a reference to the System.Data.OracleClient
-// assembly before you can run this sample.
-using System.Data.OracleClient;
-
-class Program
-{
- static void Main()
- {
- // Create a new OracleConnectionStringBuilder and
- // initialize it with a few name/value pairs.
- OracleConnectionStringBuilder builder =
- new OracleConnectionStringBuilder(GetConnectionString());
-
- // Note that the input connection string used the
- // Server key, but the new connection string uses
- // the well-known Data Source key instead.
- Console.WriteLine(builder.ConnectionString);
-
- // Pass the OracleConnectionStringBuilder an existing
- // connection string, and you can retrieve and
- // modify any of the elements.
- builder.ConnectionString = "server=OracleDemo;user id=maryc;" +
- "password=pass@word1";
-
- // Now that the connection string has been parsed,
- // you can work with individual items.
- Console.WriteLine(builder.Password);
- builder.Password = "newPassword";
- builder.PersistSecurityInfo = true;
-
- // You can refer to connection keys using strings,
- // as well. When you use this technique (the default
- // Item property in Visual Basic, or the indexer in C#),
- // you can specify any synonym for the connection string key
- // name.
- builder["Server"] = ".";
- builder["Load Balance Timeout"] = 1000;
- builder["Integrated Security"] = true;
- Console.WriteLine(builder.ConnectionString);
-
- Console.WriteLine("Press Enter to finish.");
- Console.ReadLine();
- }
-
- private static string GetConnectionString()
- {
- // To avoid storing the connection string in your code,
- // you can retrieve it from a configuration file.
- return "Server=OracleDemo;Integrated Security=true";
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/CS/source.cs
deleted file mode 100644
index 3d2b4ce1ad4..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/CS/source.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-using System;
-using System.Data;
-using System.Data.SqlClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- DemonstrateChangePassword();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error: " + ex.Message);
- }
- Console.WriteLine("Press ENTER to continue...");
- Console.ReadLine();
- }
-
- private static void DemonstrateChangePassword()
- {
- // Retrieve the connection string. In a production application,
- // this string should not be contained within the source code.
- string connectionString = GetConnectionString();
-
- using (SqlConnection cnn = new SqlConnection())
- {
- for (int i = 0; i <= 1; i++)
- {
- // Run this loop at most two times. If the first attempt fails,
- // the code checks the Number property of the SqlException object.
- // If that contains the special values 18487 or 18488, the code
- // attempts to set the user's password to a new value.
- // Assuming this succeeds, the second pass through
- // successfully opens the connection.
- // If not, the exception handler catches the exception.
- try
- {
- cnn.ConnectionString = connectionString;
- cnn.Open();
- // Once this succeeds, just get out of the loop.
- // No need to try again if the connection is already open.
- break;
- }
- catch (SqlException ex)
- {
- if (i == 0 && ((ex.Number == 18487) || (ex.Number == 18488)))
- {
- // You must reset the password.
- connectionString =
- ModifyConnectionString(connectionString,
- GetNewPassword());
- }
- else
- {
- // Bubble all other SqlException occurrences
- // back up to the caller.
- throw;
- }
- }
- }
- SqlCommand cmd = new SqlCommand(
- "SELECT ProductID, Name FROM Product", cnn);
- // Use the connection and command here...
- }
- }
-
- private static string ModifyConnectionString(
- string connectionString, string NewPassword)
- {
-
- // Use the SqlConnectionStringBuilder class to modify the
- // password portion of the connection string.
- SqlConnectionStringBuilder builder =
- new SqlConnectionStringBuilder(connectionString);
- builder.Password = NewPassword;
- return builder.ConnectionString;
- }
-
- private static string GetNewPassword()
- {
- // In a real application, you might display a modal
- // dialog box to retrieve the new password. The concepts
- // are the same as for this simple console application, however.
- Console.Write("Your password must be reset. Enter a new password: ");
- return Console.ReadLine();
- }
-
- private static string GetConnectionString()
- {
- // For this demonstration, the connection string must
- // contain both user and password information. In your own
- // application, you might want to retrieve this setting
- // from a config file, or from some other source.
-
- // In a production application, you would want to
- // display a modal form that could gather user and password
- // information.
- SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(
- "Data Source=(local);Initial Catalog=AdventureWorks");
-
- Console.Write("Enter your user id: ");
- builder.UserID = Console.ReadLine();
- Console.Write("Enter your password: ");
- builder.Password = Console.ReadLine();
-
- return builder.ConnectionString;
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/CS/source.cs
deleted file mode 100644
index 831bc0eab27..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/CS/source.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.SqlClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString =
- "Data Source=(local);User ID=ab;Password=MyPassword;" +
- "Initial Catalog=AdventureWorks";
-
- 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. Simply setting the
- // associated property values to an empty string won't
- // remove them from the connection string; you must
- // call the Remove method.
- builder.Remove("User ID");
- builder.Remove("Password");
-
- // Turn on integrated security:
- builder.IntegratedSecurity = true;
-
- Console.WriteLine("Modified: " + builder.ConnectionString);
-
- using (SqlConnection connection =
- new SqlConnection(builder.ConnectionString))
- {
- connection.Open();
- // Now use the open connection.
- Console.WriteLine("Database = " + connection.Database);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
-
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/CS/source.cs
deleted file mode 100644
index 60729fa5fdb..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/CS/source.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.SqlClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString =
- "Server=(local);Database=AdventureWorks;UID=ab;Pwd= a!Pass@@";
- Console.WriteLine("Original: " + connectString);
- SqlConnectionStringBuilder builder =
- new SqlConnectionStringBuilder(connectString);
- Console.WriteLine("Modified: " + builder.ConnectionString);
- foreach (string key in builder.Keys)
- Console.WriteLine(key + "=" + builder[key].ToString());
- Console.WriteLine("Press any key to finish.");
- Console.ReadLine();
- }
- catch (System.Collections.Generic.KeyNotFoundException ex)
- {
- Console.WriteLine("KeyNotFoundException: " + ex.Message);
- }
- catch (System.FormatException ex)
- {
- Console.WriteLine("Format exception: " + ex.Message);
- }
- }
-}
-//
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/Project.csproj
deleted file mode 100644
index 9de5f49321c..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/Project.csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- Exe
- net8.0
-
-
-
-
-
-
-
diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/source.cs
deleted file mode 100644
index 01d17ad7cd8..00000000000
--- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/source.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Data;
-//
-using System.Data.SqlClient;
-
-class Program
-{
- static void Main()
- {
- try
- {
- string connectString =
- "Data Source=(local);User ID=ab;Password=myPassw0rd;" +
- "Initial Catalog=AdventureWorks";
-
- SqlConnectionStringBuilder builder = new(connectString);
- Console.WriteLine($"Original: {builder.ConnectionString}");
-
- // Remove the User ID and Password.
- builder.Remove("User ID");
- builder.Remove("Password");
-
- // Enable integrated security.
- builder.IntegratedSecurity = true;
-
- Console.WriteLine($"Modified: {builder.ConnectionString}");
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
-}
-/* This code example produces the following output:
- * Original: Data Source=(local);Initial Catalog=AdventureWorks;User ID=ab;Password=myPassw0rd
- * Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True
- */
-//
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/VB/source.vb
deleted file mode 100644
index d1f267a15e9..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/VB/source.vb
+++ /dev/null
@@ -1,45 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.Odbc
-Module Module1
- Sub Main()
- Try
- ' Build an empty instance, just to see
- ' the contents of the keys.
- DumpBuilderContents("")
-
- ' Create a SQL Server connection string.
- DumpBuilderContents("Driver={SQL Server};Server=(local);Database=AdventureWorks;Uid=ab;Pwd=pass@word1")
-
- ' Create an Access connection string.
- DumpBuilderContents("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\info.mdb;Exclusive=1;Uid=admin;Pwd=pass@word1")
-
- ' Create an Oracle connection string.
- DumpBuilderContents("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Admin;Pwd=pass@word1;")
-
- ' Create a Sybase connection string.
- DumpBuilderContents("Driver={SYBASE ASE ODBC Driver};Srvr=SomeServer;Uid=admin;Pwd=pass@word1")
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.ArgumentException
- Console.WriteLine("Error: " & ex.Message)
- End Try
- End Sub
-
- Private Sub DumpBuilderContents(ByVal connectString As String)
- Dim builder As New OdbcConnectionStringBuilder(connectString)
- Console.WriteLine("=================")
- Console.WriteLine("Original connectString = " & connectString)
- Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/VB/source.vb
deleted file mode 100644
index c3cb019c281..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/VB/source.vb
+++ /dev/null
@@ -1,46 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.Odbc
-
-Module Module1
- Sub Main()
- Try
- ' Build an empty instance, just to see
- ' the contents of the keys.
- DumpBuilderContents("")
-
- ' Create a SQL Server connection string.
- DumpBuilderContents("Driver={SQL Server};Server=(local);Database=AdventureWorks;Uid=ab;Pwd=pass@word1")
-
- ' Create an Access connection string.
- DumpBuilderContents("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\info.mdb;Exclusive=1;Uid=admin;Pwd=pass@word1")
-
- ' Create an Oracle connection string.
- DumpBuilderContents("Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Admin;Pwd=pass@word1;")
-
- ' Create a Sybase connection string.
- DumpBuilderContents("Driver={SYBASE ASE ODBC Driver};Srvr=SomeServer;Uid=admin;Pwd=pass@word1")
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.ArgumentException
- Console.WriteLine("Error: " & ex.Message)
- End Try
- End Sub
-
- Private Sub DumpBuilderContents(ByVal connectString As String)
- Dim builder As New OdbcConnectionStringBuilder(connectString)
- Console.WriteLine("=================")
- Console.WriteLine("Original connectString = " & connectString)
- Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/Project.vbproj
new file mode 100644
index 00000000000..283a2efeb88
--- /dev/null
+++ b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/Project.vbproj
@@ -0,0 +1,12 @@
+
+
+
+ Library
+ net8
+
+
+
+
+
+
+
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/source.vb
index fe13e8382bb..228412dae3f 100644
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/source.vb
+++ b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/source.vb
@@ -1,62 +1,55 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
+Option Explicit On
+Option Strict On
'
-Imports System.Data.Odbc
+Imports System.Data.Odbc
Module Module1
- Sub Main()
- Dim builder As New OdbcConnectionStringBuilder()
- builder.Driver = "Microsoft Access Driver (*.mdb)"
-
- ' Call the Add method to explicitly add key/value
- ' pairs to the internal collection.
- builder.Add("Dbq", "C:\info.mdb")
- builder.Add("Uid", "Admin")
- builder.Add("Pwd", "pass!word1")
-
- Console.WriteLine(builder.ConnectionString)
- Console.WriteLine()
-
- ' Clear current values and reset known keys to their
- ' default values.
- builder.Clear()
-
- ' Pass the OdbcConnectionStringBuilder an existing
- ' connection string, and you can retrieve and
- ' modify any of the elements.
- builder.ConnectionString = _
- "driver={IBM DB2 ODBC DRIVER};Database=SampleDB;" & _
- "hostname=SampleServerName;port=SamplePortNum;" & _
- "protocol=TCPIP;uid=Admin;pwd=pass!word1"
-
- Console.WriteLine("protocol = " & builder("protocol").ToString())
- Console.WriteLine()
-
- ' Modify existing items:
- builder("uid") = "NewUser"
- builder("pwd") = "Pass@word2"
-
- ' Call the Remove method to remove items from
- ' the collection of key/value pairs.
- builder.Remove("port")
-
- ' Note that calling Remove on a nonexistent item does not
- ' throw an exception.
- builder.Remove("BadItem")
- Console.WriteLine(builder.ConnectionString)
- Console.WriteLine()
-
- ' The Item property is the default for the class,
- ' and setting the Item property adds the value, if
- ' necessary.
- builder("NewKey") = "newValue"
- Console.WriteLine(builder.ConnectionString)
-
- Console.WriteLine("Press Enter to finish.")
- Console.ReadLine()
- End Sub
+ Sub Main()
+ Dim builder As New OdbcConnectionStringBuilder With {
+ .Driver = "Microsoft Access Driver (*.mdb)"
+ }
+
+ ' Call the Add method to explicitly add key/value
+ ' pairs to the internal collection.
+ builder.Add("Dbq", "C:\info.mdb")
+
+ Console.WriteLine(builder.ConnectionString)
+ Console.WriteLine()
+
+ ' Clear current values and reset known keys to their
+ ' default values.
+ builder.Clear()
+
+ ' Pass the OdbcConnectionStringBuilder an existing
+ ' connection string, and you can retrieve and
+ ' modify any of the elements.
+ builder.ConnectionString =
+ "driver={IBM DB2 ODBC DRIVER};Database=SampleDB;" &
+ "hostname=SampleServerName;port=SamplePortNum;" &
+ "protocol=TCPIP"
+
+ Console.WriteLine("protocol = " & builder("protocol").ToString())
+ Console.WriteLine()
+
+ ' Call the Remove method to remove items from
+ ' the collection of key/value pairs.
+ builder.Remove("port")
+
+ ' Note that calling Remove on a nonexistent item does not
+ ' throw an exception.
+ builder.Remove("BadItem")
+ Console.WriteLine(builder.ConnectionString)
+ Console.WriteLine()
+
+ ' The Item property is the default for the class,
+ ' and setting the Item property adds the value, if
+ ' necessary.
+ builder("NewKey") = "newValue"
+ Console.WriteLine(builder.ConnectionString)
+
+ Console.WriteLine("Press Enter to finish.")
+ Console.ReadLine()
+ End Sub
End Module
'
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/VB/source.vb
deleted file mode 100644
index 4bc20705f5a..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/VB/source.vb
+++ /dev/null
@@ -1,50 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.OleDb
-
-Module Module1
- Sub Main()
- Try
- ' Build an empty instance, just to see
- ' the contents of the keys.
- DumpBuilderContents("")
-
- ' Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" & _
- "Initial Catalog=AdventureWorks;" & _
- "User Id=ab;Password=Password@1")
-
- ' Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=C:\Sample.mdb")
-
- ' Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" & _
- "User Id=userName;Password=Pass@word1;")
-
- ' Create a Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA")
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.ArgumentException
- Console.WriteLine("Error: " & ex.Message)
- End Try
- End Sub
-
- Private Sub DumpBuilderContents(ByVal connectString As String)
- Dim builder As New OleDbConnectionStringBuilder(connectString)
- Console.WriteLine("=================")
- Console.WriteLine("Original connectString = " & connectString)
- Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/VB/source.vb
deleted file mode 100644
index fe122200c07..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/VB/source.vb
+++ /dev/null
@@ -1,51 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.OleDb
-
-Module Module1
-
- Sub Main()
- Try
- ' Build an empty instance, just to see
- ' the contents of the keys.
- DumpBuilderContents("")
-
- ' Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" & _
- "Initial Catalog=AdventureWorks;" & _
- "User Id=ab;Password=Password@1")
-
- ' Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=C:\Sample.mdb")
-
- ' Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" & _
- "User Id=userName;Password=Pass@word1;")
-
- ' Create a Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA")
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.ArgumentException
- Console.WriteLine("Error: " & ex.Message)
- End Try
- End Sub
-
- Private Sub DumpBuilderContents(ByVal connectString As String)
- Dim builder As New OleDbConnectionStringBuilder(connectString)
- Console.WriteLine("=================")
- Console.WriteLine("Original connectString = " & connectString)
- Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/VB/source.vb
deleted file mode 100644
index 4bc20705f5a..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/VB/source.vb
+++ /dev/null
@@ -1,50 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.OleDb
-
-Module Module1
- Sub Main()
- Try
- ' Build an empty instance, just to see
- ' the contents of the keys.
- DumpBuilderContents("")
-
- ' Create a SQL Server connection string.
- DumpBuilderContents("Provider=sqloledb;Data Source=(local);" & _
- "Initial Catalog=AdventureWorks;" & _
- "User Id=ab;Password=Password@1")
-
- ' Create an Access connection string.
- DumpBuilderContents("Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=C:\Sample.mdb")
-
- ' Create an Oracle connection string.
- DumpBuilderContents("Provider=msdaora;Data Source=SomeOracleDb;" & _
- "User Id=userName;Password=Pass@word1;")
-
- ' Create a Sybase connection string.
- DumpBuilderContents("Provider=ASAProv;Data source=myASA")
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.ArgumentException
- Console.WriteLine("Error: " & ex.Message)
- End Try
- End Sub
-
- Private Sub DumpBuilderContents(ByVal connectString As String)
- Dim builder As New OleDbConnectionStringBuilder(connectString)
- Console.WriteLine("=================")
- Console.WriteLine("Original connectString = " & connectString)
- Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb
deleted file mode 100644
index dfc625827d2..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb
+++ /dev/null
@@ -1,32 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-' You may need to set a reference to the System.Data.OracleClient
-' assembly before running this example.
-Imports System.Data.OracleClient
-
-Module Module1
- Sub Main()
- Try
- Dim connectString As String = "Server=OracleDemo;UID=Mary;Pwd=*****"
- Console.WriteLine("Original: " & connectString)
- Dim builder As New OracleConnectionStringBuilder(connectString)
- Console.WriteLine("Modified: " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.Collections.Generic.KeyNotFoundException
- Console.WriteLine("KeyNotFoundException: " & ex.Message)
- Catch ex As System.FormatException
- Console.WriteLine("Format exception: " & ex.Message)
- End Try
- End Sub
-
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb
deleted file mode 100644
index fb201753c11..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb
+++ /dev/null
@@ -1,43 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-' You may need to set a reference to the System.Data.OracleClient
-' assembly before you can run this example.
-Imports System.Data.OracleClient
-
-Module Module1
-
- Sub Main()
- Try
- Dim connectString As String = _
- "Data Source=OracleSample;User ID=Mary;Password=*****;"
-
- Dim builder As New OracleConnectionStringBuilder(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. Simply setting the
- ' associated property values to an empty string will not
- ' remove them from the connection string; you must
- ' call the Remove method.
- builder.Remove("User ID")
- builder.Remove("Password")
-
- ' Turn on integrated security.
- builder.IntegratedSecurity = True
-
- Console.WriteLine("Modified: " & builder.ConnectionString)
-
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- End Try
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb
deleted file mode 100644
index 88c3ea8a101..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb
+++ /dev/null
@@ -1,40 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-' You may need to set a reference to the System.Data.OracleClient
-' assembly before you can run this sample.
-Imports System.Data.OracleClient
-
-Module Module1
-
- Sub Main()
- Try
- Dim connectString As String = _
- "Data Source=OracleDemo;User ID=Mary;Password=*****;"
-
- Dim builder As New OracleConnectionStringBuilder(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.
- builder.Remove("User ID")
- builder.Remove("Password")
-
- ' Turn on integrated security.
- builder.IntegratedSecurity = True
-
- Console.WriteLine("Modified: " & builder.ConnectionString)
-
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- End Try
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/VB/source.vb
deleted file mode 100644
index 27a953f07c1..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/VB/source.vb
+++ /dev/null
@@ -1,60 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-' You may need to set a reference to the System.Data.OracleClient
-' assembly before running this example.
-Imports System.Data.OracleClient
-
-Module Module1
- Sub Main()
- ' Create a new OracleConnectionStringBuilder and
- ' initialize it with a few name/value pairs.
- Dim builder As New OracleConnectionStringBuilder(GetConnectionString())
-
- ' Note that the input connection string used the
- ' Server key, but the new connection string uses
- ' the well-known Data Source key instead.
- Console.WriteLine(builder.ConnectionString)
-
- ' Pass the OracleConnectionStringBuilder an existing
- ' connection string, and you can retrieve and
- ' modify any of the elements.
- builder.ConnectionString = _
- "server=OracleDemo;user id=Mary;" & _
- "password=*****"
- ' Now that the connection string has been parsed,
- ' you can work with individual items.
- Console.WriteLine(builder.Password)
- builder.Password = "newPassword"
- builder.PersistSecurityInfo = True
-
- ' You can refer to connection keys using strings,
- ' as well. When you use this technique (the default
- ' Item property in Visual Basic, or the indexer in C#),
- ' you can specify any synonym for the connection string key
- ' name.
- builder("Server") = "NewDemo"
- builder("Load Balance Timeout") = 1000
-
- ' The Item property is the default for the class,
- ' and setting the Item property adds the value to the
- ' dictionary, if necessary.
- builder.Item("Integrated Security") = True
- Console.WriteLine(builder.ConnectionString)
-
- Console.WriteLine("Press Enter to finish.")
- Console.ReadLine()
- End Sub
-
- Private Function GetConnectionString() As String
- ' To avoid storing the connection string in your code,
- ' you can retrieve it from a configuration file.
- Return "Server=OracleDemo;Integrated Security=True;" & _
- "Unicode=True"
- End Function
-
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/VB/source.vb
deleted file mode 100644
index bc505c59b45..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnection.ChangePassword/VB/source.vb
+++ /dev/null
@@ -1,93 +0,0 @@
-'
-Option Explicit On
-Option Strict On
-
-Imports System.Data
-Imports System.Data.SqlClient
-
-Module Module1
- Sub Main()
- Try
- DemonstrateChangePassword()
- Catch ex As Exception
- Console.WriteLine("Error: " & ex.Message)
- End Try
- Console.WriteLine("Press ENTER to continue...")
- Console.ReadLine()
- End Sub
-
- Private Sub DemonstrateChangePassword()
- Dim connectionString As String = GetConnectionString()
- Using cnn As New SqlConnection()
- For i As Integer = 0 To 1
- ' Run this loop at most two times. If the first attempt fails,
- ' the code checks the Number property of the SqlException object.
- ' If that contains the special values 18487 or 18488, the code
- ' attempts to set the user's password to a new value.
- ' Assuming this succeeds, the second pass through
- ' successfully opens the connection.
- ' If not, the exception handler catches the exception.
- Try
- cnn.ConnectionString = connectionString
- cnn.Open()
- ' Once this succeeds, just get out of the loop.
- ' No need to try again if the connection is already open.
- Exit For
-
- Catch ex As SqlException _
- When (i = 0 And (ex.Number = 18487 Or ex.Number = 18488))
- ' You must reset the password.
- connectionString = ModifyConnectionString( _
- connectionString, GetNewPassword())
-
- Catch ex As SqlException
- ' Bubble all other SqlException occurrences
- ' back up to the caller.
- Throw
- End Try
- Next
- Dim cmd As New SqlCommand("SELECT ProductID, Name FROM Product", cnn)
- ' Use the connection and command here...
- End Using
- End Sub
-
- Private Function ModifyConnectionString( _
- ByVal connectionString As String, ByVal NewPassword As String) As String
-
- ' Use the SqlConnectionStringBuilder class to modify the
- ' password portion of the connection string.
- Dim builder As New SqlConnectionStringBuilder(connectionString)
- builder.Password = NewPassword
- Return builder.ConnectionString
- End Function
-
- Private Function GetNewPassword() As String
- ' In a real application, you might display a modal
- ' dialog box to retrieve the new password. The concepts
- ' are the same as for this simple console application, however.
- Console.Write("Your password must be reset. Enter a new password: ")
- Return Console.ReadLine()
- End Function
-
- Private Function GetConnectionString() As String
- ' For this demonstration, the connection string must
- ' contain both user and password information. In your own
- ' application, you might want to retrieve this setting
- ' from a config file, or from some other source.
-
- ' In a production application, you would want to
- ' display a modal form that could gather user and password
- ' information.
- Dim builder As New SqlConnectionStringBuilder( _
- "Data Source=(local);Initial Catalog=AdventureWorks")
-
- Console.Write("Enter your user id: ")
- builder.UserID = Console.ReadLine()
- Console.Write("Enter your password: ")
- builder.Password = Console.ReadLine()
-
- Return builder.ConnectionString
- End Function
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/VB/source.vb
deleted file mode 100644
index 3892bb096b7..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/VB/source.vb
+++ /dev/null
@@ -1,47 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.SqlClient
-
-Module Module1
- Sub Main()
- Try
- Dim connectString As String = _
- "Data Source=(local);User ID=ab;Password=MyPassword;" & _
- "Initial Catalog=AdventureWorks"
-
- Dim builder As 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. Simply setting the
- ' associated property values to an empty string won't
- ' remove them from the connection string; you must
- ' call the Remove method.
- builder.Remove("User ID")
- builder.Remove("Password")
-
- ' Turn on integrated security.
- builder.IntegratedSecurity = True
-
- Console.WriteLine("Modified: " & builder.ConnectionString)
-
- Using connection As New SqlConnection(builder.ConnectionString)
- connection.Open()
- ' Now use the open connection.
- Console.WriteLine("Database = " & connection.Database)
- End Using
-
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- End Try
-
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/VB/source.vb
deleted file mode 100644
index 8f3d128e016..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/VB/source.vb
+++ /dev/null
@@ -1,30 +0,0 @@
-Option Explicit
-Option Strict
-
-Imports System.Data
-'
-Imports System.Data.SqlClient
-
-Module Module1
- Sub Main()
- Try
- Dim connectString As String = _
- "Server=(local);Database=AdventureWorks;UID=ab;Pwd=a!Pass@@"
- Console.WriteLine("Original: " & connectString)
- Dim builder As New SqlConnectionStringBuilder(connectString)
- Console.WriteLine("Modified: " & builder.ConnectionString)
- For Each key As String In builder.Keys
- Console.WriteLine(key & "=" & builder.Item(key).ToString)
- Next
- Console.WriteLine("Press any key to finish.")
- Console.ReadLine()
-
- Catch ex As System.Collections.Generic.KeyNotFoundException
- Console.WriteLine("KeyNotFoundException: " & ex.Message)
- Catch ex As System.FormatException
- Console.WriteLine("Format exception: " & ex.Message)
- End Try
- End Sub
-End Module
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/Project.vbproj
deleted file mode 100644
index 9de5f49321c..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/Project.vbproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- Exe
- net8.0
-
-
-
-
-
-
-
diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/source.vb
deleted file mode 100644
index 830efa45218..00000000000
--- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/source.vb
+++ /dev/null
@@ -1,35 +0,0 @@
-Option Explicit On
-Option Strict On
-Imports System.Data.SqlClient
-
-Module Module1
- Sub Main()
- Try
- '
- Dim connectString As String =
- "Data Source=(local);User ID=ab;Password=a1Pass@@11;" &
- "Initial Catalog=AdventureWorks"
-
- Dim builder As New SqlConnectionStringBuilder(connectString)
- Console.WriteLine("Original: " & builder.ConnectionString)
-
- ' Remove the user ID and password.
- builder.Remove("User ID")
- builder.Remove("Password")
-
- ' Turn on integrated security:
- builder.IntegratedSecurity = True
-
- Console.WriteLine("Modified: " & builder.ConnectionString)
-
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- End Try
-
- ' This code produces the following output:
- ' Original: Data Source=(local);Initial Catalog=AdventureWorks;User ID=ab;Password=a1Pass@@11
- ' Modified: Data Source = (local);Initial Catalog=AdventureWorks;Integrated Security=True
- '
- End Sub
-End Module
-
diff --git a/xml/System.Data.Common/DbConnectionStringBuilder.xml b/xml/System.Data.Common/DbConnectionStringBuilder.xml
index 12925201d84..df16cd8d8ae 100644
--- a/xml/System.Data.Common/DbConnectionStringBuilder.xml
+++ b/xml/System.Data.Common/DbConnectionStringBuilder.xml
@@ -2843,27 +2843,6 @@ Unable to retrieve value for null key.
The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the are reflected in the .
-
-
-## Examples
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Values/VB/source.vb" id="Snippet1":::
-
- Displays the following output:
-
-```
-MSDataShape.1
-false
-MSDAORA
-orac
-username
-*******
-```
-
]]>
Connection Strings in ADO.NET
diff --git a/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml b/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml
index cd4decd20aa..eb6cb7c19f1 100644
--- a/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml
+++ b/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml
@@ -83,9 +83,6 @@ Driver={SQL Server};Server="MyServer;NewValue=Bad"
## Examples
The following console application builds connection strings for several ODBC databases. First, the example creates a connection string for a Microsoft Access database. It then creates a connection string for an IBM DB2 database. The example also parses an existing connection string, and demonstrates various ways of manipulating the contents of the connection string.
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/VB/source.vb" id="Snippet1":::
@@ -157,19 +154,7 @@ Driver={SQL Server};Server="MyServer;NewValue=Bad"
property explicitly. The behavior is the same either way.
-
-
-
-## Examples
- The following example creates multiple instances, passing a different connection string to the constructor in each case. Note that the ordering of elements within the connection string may be modified when you retrieve the property. Also note that keys other than the predefined "Dsn" and "Driver" keys are converted to lowercase by the class.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Multiple/VB/source.vb" id="Snippet1":::
+You can pass a connection string in the constructor, or you can set the property explicitly. The behavior is the same either way.
]]>
@@ -431,18 +416,8 @@ Driver={SQL Server};Server="MyServer;NewValue=Bad"
is the same order as the associated values in the returned by the property.
-
-
-
-## Examples
- The following console application example creates a new . The code loops through the returned by the property displaying the key/value pairs.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder.Keys/VB/source.vb" id="Snippet1":::
+The order of the values in the is the same order as the associated values in the returned by the property.
]]>
diff --git a/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml b/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml
index a12f31cf983..93b39a5d2fc 100644
--- a/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml
+++ b/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml
@@ -164,22 +164,10 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sample.mdb;User ID="Admin;NewVal
property, either directly (by setting the property) or by passing a connection string as a parameter to the constructor, may affect the set of key/value pairs that are contained within the instance. Setting the property to "sqloledb," for example, adds all the standard SQL connection string properties. See the example in this topic for a demonstration of this behavior.
+ Setting the property, either directly (by setting the property) or by passing a connection string as a parameter to the constructor, might affect the set of key/value pairs that are contained within the instance. Setting the property to "sqloledb," for example, adds all the standard SQL connection string properties.
For some providers, assigning a connection string within the constructor causes the order of supplied key/value pairs to be rearranged.
-
-
-## Examples
- The following example creates multiple instances, passing a different connection string to the constructor in each case. Note how setting the provider associated with the connection changes the set of predefined key/value pairs within the object's collection.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Ctor/VB/source.vb" id="Snippet1":::
-
]]>
The connection string is incorrectly formatted (perhaps missing the required "=" within a key/value pair).
@@ -481,19 +469,7 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sample.mdb;User ID="Admin;NewVal
is unspecified, but it is the same order as the associated values in the returned by the property.
-
-
-
-## Examples
- The following console application example creates a new . The code loops through the returned by the property displaying the key/value pairs.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Keys/VB/source.vb" id="Snippet1":::
+The order of the values in the is unspecified, but it is the same order as the associated values in the returned by the property.
]]>
@@ -654,21 +630,10 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sample.mdb;User ID="Admin;NewVal
## Remarks
If the value passed in is null when you try to set the property, the property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is `String.Empty`. This property corresponds to the "Provider" key within the connection string.
- Setting the value of the `Provider` property, either directly (by setting the property) or by passing a connection string as a parameter to the constructor, may affect the set of key/value pairs that are contained within the instance. Setting the property to "sqloledb," for example, adds all the standard SQL connection string properties. See the example in this topic for a demonstration of this behavior.
+ Setting the value of the `Provider` property, either directly (by setting the property) or by passing a connection string as a parameter to the constructor, might affect the set of key/value pairs that are contained within the instance. Setting the property to "sqloledb," for example, adds all the standard SQL connection string properties. See the example in this topic for a demonstration of this behavior.
For some providers, assigning a connection string within the constructor causes the order of supplied key/value pairs to be rearranged.
-
-
-## Examples
- The following example creates multiple instances, passing a different connection string to the constructor in each case. Note how setting the provider associated with the connection changes the set of predefined key/value pairs within the object's collection.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Provider/VB/source.vb" id="Snippet1":::
-
]]>
Connection String Builders
diff --git a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml
index a2d039681a5..844b98997b3 100644
--- a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml
+++ b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml
@@ -125,20 +125,8 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"
class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the property of the object is retrieved, the string contains only key/value pairs in which the value is different from the default value for the item.
-
-
-## Examples
- The following example supplies a simple connection string in the object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each items. Also note that the class converts synonyms for the well-known keys so that they are consistent with the well-known names.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb" id="Snippet1":::
-
]]>
Invalid key name within the connection string.
@@ -374,23 +362,10 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"
property of the object.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb" id="Snippet1":::
-
]]>
- Building Connection Strings
@@ -834,38 +809,26 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"
method returns a value that indicates its success, it is not necessary to look for the existence of a key before trying to remove the key/value pair from the instance. Because the maintains a fixed-size collection of key/value pairs, calling the method just resets the value of the key/value pair back to its default value.
-
- Because the collection of keys supported by the is fixed, every item within the collection has a known default value.
-
- The following table lists the keys, and the value for each when the is first initialized, or after the method has been called:
-
-|Key|Default value|
-|---------|-------------------|
-|Data Source|Empty string|
-|Persist Security Info|False|
-|Integrated Security|False|
-|User ID|Empty string|
-|Password|Empty string|
-|Enlist|True|
-|Pooling|True|
-|Min Pool Size|0|
-|Max Pool Size|100|
-|Unicode|False|
-|Load Balance Timeout|0|
-|Omit Oracle Connection Name|False|
-
-
-
-## Examples
- The following example converts an existing connection string from using Windows Authentication to using integrated security. The example works by removing the user name and password from the connection string, and then setting the property of the object.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb" id="Snippet1":::
+The method returns a value that indicates its success, so it's not necessary to look for the existence of a key before trying to remove the key/value pair from the instance. Calling the method just resets the value of the key/value pair back to its default value. That's because the maintains a fixed-size collection of key/value pairs
+
+The collection of keys supported by the is fixed, so every item within the collection has a known default value.
+
+ The following table lists the keys, and the value for each when the is first initialized, or after the method has been called.
+
+| Key | Default value |
+|-----------------------------|---------------|
+| Data Source | Empty string |
+| Persist Security Info | False |
+| Integrated Security | False |
+| User ID | Empty string |
+| Password | Empty string |
+| Enlist | True |
+| Pooling | True |
+| Min Pool Size | 0 |
+| Max Pool Size | 100 |
+| Unicode | False |
+| Load Balance Timeout | 0 |
+| Omit Oracle Connection Name | False |
]]>
diff --git a/xml/System.Data.SqlClient/SqlConnection.xml b/xml/System.Data.SqlClient/SqlConnection.xml
index 2cc9f5251fe..ddd0200e360 100644
--- a/xml/System.Data.SqlClient/SqlConnection.xml
+++ b/xml/System.Data.SqlClient/SqlConnection.xml
@@ -746,12 +746,12 @@ using (SqlConnection connection = new SqlConnection(connectionString))
The connection string that contains enough information to connect to the server that you want. The connection string must contain the user ID and the current password.
The new password to set. This password must comply with any password security policy set on the server, including minimum length, requirements for specific characters, and so on.
- Changes the SQL Server password for the user indicated in the connection string to the supplied new password.
+ Changes the SQL Server password for the user indicated in the connection string to the specified new password.
The connection string includes the option to use integrated security.
diff --git a/xml/System.Data.SqlClient/SqlConnectionStringBuilder.xml b/xml/System.Data.SqlClient/SqlConnectionStringBuilder.xml
index 987e4315815..abbdcd68fda 100644
--- a/xml/System.Data.SqlClient/SqlConnectionStringBuilder.xml
+++ b/xml/System.Data.SqlClient/SqlConnectionStringBuilder.xml
@@ -167,19 +167,7 @@ The following console application builds connection strings for a SQL Server dat
class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the `ConnectionString` property of the object is retrieved, the string contains only key/value pairs in which the value is not the default value for the item.
-
-
-
-## Examples
- The following example supplies a simple SQL Server connection string in the object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each item. Also note that the class converts synonyms for the well-known keys so that they are consistent with the well-known names.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Password/VB/source.vb" id="Snippet1":::
+The class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the `ConnectionString` property of the object is retrieved, the string contains only key/value pairs in which the value is not the default value for the item.
]]>
@@ -1280,19 +1268,7 @@ False
property of the object.
-
-> [!NOTE]
-> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.IntegratedSecurity/VB/source.vb" id="Snippet1":::
+This property corresponds to the "Integrated Security" and "trusted_connection" keys within the connection string.
]]>
@@ -2081,15 +2057,6 @@ False
| User Instance | False |
| Workstation ID | Empty string |
-## Examples
-
-The following example converts an existing connection string from using SQL Server Authentication to Windows Authentication (integrated security). The example works by removing the user name and password from the connection string, and then setting the property of the object.
-
-[!INCLUDE[ROPC warning](~/includes/ropc-warning.md)]
-
- :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/CS/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlConnectionStringBuilder.Remove/VB/source.vb" id="Snippet1":::
-
]]>