From 4c51b30c2a352b11f3248338acf7091af35fe21e Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Fri, 13 Sep 2019 16:00:25 -0700 Subject: [PATCH 01/19] add more code samples from api reference --- doc/samples/SqlConnectionStringBuilder.cs | 54 ++++++++++++ doc/samples/SqlConnectionStringBuilder2.cs | 25 ++++++ doc/samples/SqlConnectionStringBuilder3.cs | 34 +++++++ ...ConnectionStringBuilder_ApplicationName.cs | 33 +++++++ ...ionStringBuilder_AsynchronousProcessing.cs | 88 +++++++++++++++++++ ...onnectionStringBuilder_AttachDBFilename.cs | 38 ++++++++ .../SqlConnectionStringBuilder_Clear.cs | 25 ++++++ ...lConnectionStringBuilder_ConnectTimeout.cs | 33 +++++++ .../SqlConnectionStringBuilder_ContainsKey.cs | 41 +++++++++ .../SqlConnectionStringBuilder_DataSource.cs | 26 ++++++ ...lConnectionStringBuilder_InitialCatalog.cs | 48 ++++++++++ ...nectionStringBuilder_IntegratedSecurity.cs | 52 +++++++++++ .../SqlConnectionStringBuilder_Keys.cs | 26 ++++++ ...nStringBuilder_MultipleActiveResultSets.cs | 29 ++++++ .../SqlConnectionStringBuilder_Password.cs | 25 ++++++ .../SqlConnectionStringBuilder_Remove.cs | 47 ++++++++++ .../SqlConnectionStringBuilder_TryGetValue.cs | 61 +++++++++++++ .../SqlConnectionStringBuilder_Values.cs | 29 ++++++ 18 files changed, 714 insertions(+) create mode 100644 doc/samples/SqlConnectionStringBuilder.cs create mode 100644 doc/samples/SqlConnectionStringBuilder2.cs create mode 100644 doc/samples/SqlConnectionStringBuilder3.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_ApplicationName.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_AsynchronousProcessing.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_Clear.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_ContainsKey.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_DataSource.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_Keys.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_MultipleActiveResultSets.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_Password.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_Remove.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_TryGetValue.cs create mode 100644 doc/samples/SqlConnectionStringBuilder_Values.cs diff --git a/doc/samples/SqlConnectionStringBuilder.cs b/doc/samples/SqlConnectionStringBuilder.cs new file mode 100644 index 0000000000..723f87f722 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder.cs @@ -0,0 +1,54 @@ +using System; +// +using System.Data; +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + // Create a new SqlConnectionStringBuilder and + // initialize it with a few name/value pairs. + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(GetConnectionString()); + + // 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 SqlConnectionStringBuilder an existing + // connection string, and you can retrieve and + // modify any of the elements. + builder.ConnectionString = "server=(local);user id=ab;" + + "password= a!Pass113;initial catalog=AdventureWorks"; + + // Now that the connection string has been parsed, + // you can work with individual items. + Console.WriteLine(builder.Password); + builder.Password = "new@1Password"; + builder.AsynchronousProcessing = 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["Connect Timeout"] = 1000; + builder["Trusted_Connection"] = 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=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks"; + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder2.cs b/doc/samples/SqlConnectionStringBuilder2.cs new file mode 100644 index 0000000000..16dae6dcab --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder2.cs @@ -0,0 +1,25 @@ +using System; +using System.Data; +using Microsoft.Data.SqlClient; + +// +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(); + builder["Data Source"] = "(local)"; + builder["Integrated Security"] = true; + builder["Initial Catalog"] = "AdventureWorks"; + + // Overwrite the existing value for the Data Source value. + builder["Data Source"] = "."; + + Console.WriteLine(builder.ConnectionString); + Console.WriteLine(); + Console.WriteLine("Press Enter to continue."); + Console.ReadLine(); + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder3.cs b/doc/samples/SqlConnectionStringBuilder3.cs new file mode 100644 index 0000000000..ec14c38184 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder3.cs @@ -0,0 +1,34 @@ +using System; +using System.Data; +// +using Microsoft.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/doc/samples/SqlConnectionStringBuilder_ApplicationName.cs b/doc/samples/SqlConnectionStringBuilder_ApplicationName.cs new file mode 100644 index 0000000000..81db8b8f45 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_ApplicationName.cs @@ -0,0 +1,33 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + try + { + string connectString = "Server=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=true"; + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(connectString); + Console.WriteLine("Original: " + builder.ConnectionString); + Console.WriteLine("ApplicationName={0}", + builder.ApplicationName); + + builder.ApplicationName = "My Application"; + Console.WriteLine("Modified: " + builder.ConnectionString); + + Console.WriteLine("Press any key to finish."); + Console.ReadLine(); + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_AsynchronousProcessing.cs b/doc/samples/SqlConnectionStringBuilder_AsynchronousProcessing.cs new file mode 100644 index 0000000000..272a67cb49 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_AsynchronousProcessing.cs @@ -0,0 +1,88 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; +using System.Threading; + +class Program +{ + static void Main() + { + // Create a SqlConnectionStringBuilder instance, + // and ensure that it is set up for asynchronous processing. + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(GetConnectionString()); + // Asynchronous method calls won't work unless you + // have added this option, or have added + // the clause "Asynchronous Processing=true" + // to the connection string. + builder.AsynchronousProcessing = true; + + string commandText = + "UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " + + "WHERE ReorderPoint IS NOT Null;" + + "WAITFOR DELAY '0:0:3';" + + "UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " + + "WHERE ReorderPoint IS NOT Null"; + RunCommandAsynchronously(commandText, builder.ConnectionString); + + Console.WriteLine("Press any key 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 "Data Source=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks"; + } + + private static void RunCommandAsynchronously(string commandText, + string connectionString) + { + // Given command text and connection string, asynchronously execute + // the specified command against the connection. For this example, + // the code displays an indicator as it's working, verifying the + // asynchronous behavior. + using (SqlConnection connection = new SqlConnection(connectionString)) + { + try + { + int count = 0; + SqlCommand command = new SqlCommand(commandText, connection); + connection.Open(); + IAsyncResult result = command.BeginExecuteNonQuery(); + while (!result.IsCompleted) + { + Console.WriteLine("Waiting {0}.", count); + // Wait for 1/10 second, so the counter + // doesn't consume all available resources + // on the main thread. + Thread.Sleep(100); + count += 1; + } + Console.WriteLine("Command complete. Affected {0} rows.", + command.EndExecuteNonQuery(result)); + + } + catch (SqlException ex) + { + Console.WriteLine( + "Error {0}: Microsoft.Data.SqlClient.SqlConnectionStringBuilder", + ex.Number, ex.Message); + } + catch (InvalidOperationException ex) + { + Console.WriteLine("Error: {0}", ex.Message); + } + catch (Exception ex) + { + // You might want to pass these errors + // back out to the caller. + Console.WriteLine("Error: {0}", ex.Message); + } + } + } +} +// \ No newline at end of file diff --git a/doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs b/doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs new file mode 100644 index 0000000000..0b0402b1ec --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs @@ -0,0 +1,38 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + try + { + string connectString = + "Server=(local);" + + "Integrated Security=true"; + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(connectString); + Console.WriteLine("Original: " + builder.ConnectionString); + Console.WriteLine("AttachDBFileName={0}", builder.AttachDBFilename); + + builder.AttachDBFilename = @"C:\MyDatabase.mdf"; + Console.WriteLine("Modified: " + builder.ConnectionString); + + using (SqlConnection connection = new SqlConnection(builder.ConnectionString)) + { + connection.Open(); + // Now use the open connection. + Console.WriteLine("Database = " + connection.Database); + } + Console.WriteLine("Press any key to finish."); + Console.ReadLine(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_Clear.cs b/doc/samples/SqlConnectionStringBuilder_Clear.cs new file mode 100644 index 0000000000..b91587ebe0 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_Clear.cs @@ -0,0 +1,25 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); + builder.DataSource = "(local)"; + builder.IntegratedSecurity = true; + builder.InitialCatalog = "AdventureWorks"; + Console.WriteLine("Initial connection string: " + builder.ConnectionString); + + builder.Clear(); + Console.WriteLine("After call to Clear, count = " + builder.Count); + Console.WriteLine("Cleared connection string: " + builder.ConnectionString); + Console.WriteLine(); + + Console.WriteLine("Press Enter to continue."); + Console.ReadLine(); + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs b/doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs new file mode 100644 index 0000000000..7c700150bc --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs @@ -0,0 +1,33 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + try + { + string connectString = + "Server=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=true"; + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(connectString); + Console.WriteLine("Original: " + builder.ConnectionString); + Console.WriteLine("ConnectTimeout={0}", + builder.ConnectTimeout); + builder.ConnectTimeout = 100; + Console.WriteLine("Modified: " + builder.ConnectionString); + + Console.WriteLine("Press any key to finish."); + Console.ReadLine(); + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_ContainsKey.cs b/doc/samples/SqlConnectionStringBuilder_ContainsKey.cs new file mode 100644 index 0000000000..7a9fd3b13a --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_ContainsKey.cs @@ -0,0 +1,41 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(GetConnectionString()); + Console.WriteLine("Connection string = " + builder.ConnectionString); + + // Keys you have provided return true. + Console.WriteLine(builder.ContainsKey("Server")); + + // Comparison is case insensitive, and synonyms + // are automatically converted to their "well-known" + // names. + Console.WriteLine(builder.ContainsKey("Database")); + + // Keys that are valid but have not been set return true. + Console.WriteLine(builder.ContainsKey("Max Pool Size")); + + // Keys that do not exist return false. + Console.WriteLine(builder.ContainsKey("MyKey")); + + Console.WriteLine("Press Enter to continue."); + 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=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks"; + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_DataSource.cs b/doc/samples/SqlConnectionStringBuilder_DataSource.cs new file mode 100644 index 0000000000..14ef063e11 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_DataSource.cs @@ -0,0 +1,26 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder( + "Network Address=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks"); + + // Display the connection string, which should now + // contain the "Data Source" key, as opposed to the + // supplied "Network Address". + Console.WriteLine(builder.ConnectionString); + + // Retrieve the DataSource property. + Console.WriteLine("DataSource = " + builder.DataSource); + + Console.WriteLine("Press any key to continue."); + Console.ReadLine(); + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs b/doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs new file mode 100644 index 0000000000..576fe9e8c0 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs @@ -0,0 +1,48 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + try + { + string connectString = "Data Source=(local);" + + "Integrated Security=true"; + + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(connectString); + Console.WriteLine("Original: " + builder.ConnectionString); + + // Normally, you could simply set the InitialCatalog + // property of the SqlConnectionStringBuilder object. This + // example uses the default Item property (the C# indexer) + // and the "Database" string, simply to demonstrate that + // setting the value in this way results in the same + // connection string: + builder["Database"] = "AdventureWorks"; + Console.WriteLine("builder.InitialCatalog = " + + builder.InitialCatalog); + 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/doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs b/doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs new file mode 100644 index 0000000000..c6e572128b --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs @@ -0,0 +1,52 @@ +using System; +using System.Data; +// +using Microsoft.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/doc/samples/SqlConnectionStringBuilder_Keys.cs b/doc/samples/SqlConnectionStringBuilder_Keys.cs new file mode 100644 index 0000000000..1c31194cb1 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_Keys.cs @@ -0,0 +1,26 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(); + builder.DataSource = "(local)"; + builder.IntegratedSecurity = true; + builder.InitialCatalog = "AdventureWorks"; + + // Loop through the collection of keys, displaying + // the key and value for each item: + foreach (string key in builder.Keys) + Console.WriteLine("{0}={1}", key, builder[key]); + + Console.WriteLine(); + Console.WriteLine("Press Enter to continue."); + Console.ReadLine(); + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_MultipleActiveResultSets.cs b/doc/samples/SqlConnectionStringBuilder_MultipleActiveResultSets.cs new file mode 100644 index 0000000000..849951f4b1 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_MultipleActiveResultSets.cs @@ -0,0 +1,29 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); + builder.DataSource = "(local)"; + builder.IntegratedSecurity = true; + builder.InitialCatalog = "AdventureWorks"; + + // The connection does not allow multiple active result sets + // by default, so this line of code explicitly + // enables this feature. Note that this feature is + // only available when programming against SQL Server 2005 + // or later. + builder.MultipleActiveResultSets = true; + + Console.WriteLine(builder.ConnectionString); + Console.WriteLine(); + + Console.WriteLine("Press Enter to continue."); + Console.ReadLine(); + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_Password.cs b/doc/samples/SqlConnectionStringBuilder_Password.cs new file mode 100644 index 0000000000..05d97add53 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_Password.cs @@ -0,0 +1,25 @@ +// +using System; +using Microsoft.Data.SqlClient; + +class Program { + public static void Main() { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); + + builder["Password"] = null; + string aa = builder.Password; + Console.WriteLine(aa.Length); + + builder["Password"] = "??????"; + aa = builder.Password; + Console.WriteLine(aa.Length); + + try { + builder.Password = null; + } + catch (ArgumentNullException e) { + Console.WriteLine("{0}", e); + } + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_Remove.cs b/doc/samples/SqlConnectionStringBuilder_Remove.cs new file mode 100644 index 0000000000..7de94386a1 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_Remove.cs @@ -0,0 +1,47 @@ +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"; + + 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. + 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/doc/samples/SqlConnectionStringBuilder_TryGetValue.cs b/doc/samples/SqlConnectionStringBuilder_TryGetValue.cs new file mode 100644 index 0000000000..6724adeb94 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_TryGetValue.cs @@ -0,0 +1,61 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); + builder.ConnectionString = GetConnectionString(); + + // Call TryGetValue method for multiple + // key names. Note that these keys are converted + // to well-known synonynms for data retrieval. + DisplayValue(builder, "Data Source"); + DisplayValue(builder, "Trusted_Connection"); + DisplayValue(builder, "InvalidKey"); + DisplayValue(builder, null); + + Console.WriteLine("Press any key to continue."); + Console.ReadLine(); + } + + private static void DisplayValue( + SqlConnectionStringBuilder builder, string key) + { + object value = null; + + // Although TryGetValue handles missing keys, + // it doesn't handle passing in a null + // key. This example traps for that particular error, but + // passes any other unknown exceptions back out to the + // caller. + try + { + if (builder.TryGetValue(key, out value)) + { + Console.WriteLine("{0}='{1}'", key, value); + } + else + { + Console.WriteLine("Unable to retrieve value for '{0}'", key); + } + } + catch (ArgumentNullException) + { + Console.WriteLine("Unable to retrieve value for null key."); + } + } + + private static string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file. + return "Server=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks"; + } +} +// diff --git a/doc/samples/SqlConnectionStringBuilder_Values.cs b/doc/samples/SqlConnectionStringBuilder_Values.cs new file mode 100644 index 0000000000..57cc6f4135 --- /dev/null +++ b/doc/samples/SqlConnectionStringBuilder_Values.cs @@ -0,0 +1,29 @@ +using System; +using System.Data; +// +using Microsoft.Data.SqlClient; + +class Program +{ + static void Main() + { + SqlConnectionStringBuilder builder = + new SqlConnectionStringBuilder(GetConnectionString()); + + // Loop through each of the values, displaying the contents. + foreach (object value in builder.Values) + Console.WriteLine(value); + + Console.WriteLine("Press any key to continue."); + Console.ReadLine(); + } + + private static string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file. + return "Data Source=(local);Integrated Security=SSPI;" + + "Initial Catalog=AdventureWorks; Asynchronous Processing=true"; + } +} +// From 3a76c1cdde675ea7441ca8818afb10a01fe59e67 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Fri, 13 Sep 2019 16:27:15 -0700 Subject: [PATCH 02/19] add documentation xml files --- .../SqlConnectionColumnEncryptionSetting.xml | 15 + .../SqlConnectionStringBuilder.xml | 891 ++++++++++++ .../SqlCredential.xml | 88 ++ .../SqlDataAdapter.xml | 501 +++++++ .../SqlDataReader.xml | 1212 +++++++++++++++++ .../SqlDependency.xml | 257 ++++ .../SqlEnclaveAttestationParameters.xml | 33 + .../SqlEnclaveSession.xml | 29 + .../Microsoft.Data.SqlClient/SqlError.xml | 207 +++ .../SqlErrorCollection.xml | 114 ++ .../Microsoft.Data.SqlClient/SqlException.xml | 367 +++++ .../SqlInfoMessageEventArgs.xml | 52 + .../SqlInfoMessageEventHandler.xml | 18 + .../SqlNotificationEventArgs.xml | 41 + .../SqlNotificationInfo.xml | 73 + .../SqlNotificationSource.xml | 51 + .../SqlNotificationType.xml | 25 + .../Microsoft.Data.SqlClient/SqlParameter.xml | 653 +++++++++ .../SqlParameterCollection.xml | 366 +++++ .../SqlRowUpdatedEventArgs.xml | 60 + .../SqlRowUpdatedEventHandler.xml | 20 + .../SqlRowUpdatingEventArgs.xml | 65 + .../SqlRowUpdatingEventHandler.xml | 22 + .../SqlRowsCopiedEventArgs.xml | 51 + .../SqlRowsCopiedEventHandler.xml | 11 + .../SqlTransaction.xml | 187 +++ 26 files changed, 5409 insertions(+) create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlError.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlException.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml new file mode 100644 index 0000000000..ccc3359d3e --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml @@ -0,0 +1,15 @@ + + + + + Note that these settings cannot be used to bypass encryption and gain access to plaintext data. For details, see Always Encrypted (Database Engine). + To be added. + + + Specifies the connection does not use Always Encrypted. Should be used if no queries sent over the connection access encrypted columns. + + + Enables Always Encrypted functionality for the connection. Query parameters that correspond to encrypted columns will be transparently encrypted and query results from encrypted columns will be transparently decrypted. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml new file mode 100644 index 0000000000..85f365a9b1 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml @@ -0,0 +1,891 @@ + + + + + Provides a simple way to create and manage the contents of connection strings used by the class. + + class to build and modify connection strings. The class also makes it easy to manage connection strings stored in an application configuration file. + + The performs checks for valid key/value pairs. Therefore, you cannot use this class to create invalid connection strings; trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms and can translate from a synonym to the corresponding well-known key name. + + For example, when you use the **Item** property to retrieve a value, you can specify a string that contains any synonym for the key you need. For example, you can specify "Network Address", "addr", or any other acceptable synonym for this key within a connection string when you use any member that requires a string that contains the key name, such as the **Item** property or the method. See the property for a full list of acceptable synonyms. + + The **Item** property handles tries to insert malicious entries. For example, the following code, using the default Item property (the indexer, in C#) correctly escapes the nested key/value pair: + +```vb +Dim builder As New Microsoft.Data.SqlClient.SqlConnectionStringBuilder +builder("Data Source") = "(local)" +builder("Integrated Security") = True +builder("Initial Catalog") = "AdventureWorks;NewValue=Bad" +Console.WriteLine(builder.ConnectionString) +``` + +```csharp +Microsoft.Data.SqlClient.SqlConnectionStringBuilder builder = + new Microsoft.Data.SqlClient.SqlConnectionStringBuilder(); +builder["Data Source"] = "(local)"; +builder["integrated Security"] = true; +builder["Initial Catalog"] = "AdventureWorks;NewValue=Bad"; +Console.WriteLine(builder.ConnectionString); + +``` + + The result is the following connection string that handles the invalid value in a safe manner: + +``` +Source=(local);Initial Catalog="AdventureWorks;NewValue=Bad"; +Integrated Security=True +``` + + + +## Examples + The following console application builds connection strings for a SQL Server database. The code uses a class to create the connection string, and then passes the property of the instance to the constructor of the connection class. The example also parses an existing connection string and demonstrates various ways of manipulating the connection string's contents. + +> [!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-csharp[SqlConnectionStringBuilder#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder.cs#1)] + + ]]> + + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + To be added. + + + The basis for the object's internal connection information. Parsed into name/value pairs. Invalid key names raise . + Initializes a new instance of the class. The provided connection string provides the data for the instance's internal connection information. + + 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-csharp[SqlConnectionStringBuilder3#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder3.cs#1)] + + ]]> + + Invalid key name within the connection string. + Invalid value within the connection string (specifically, when a Boolean or numeric value was expected but not supplied). + The supplied is not valid. + + + Declares the application workload type when connecting to a database in an SQL Server Availability Group. You can set the value of this property with . For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](~/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md). + Returns the current value of the property (a value of type ). + To be added. + ADO.NET Overview + + + Gets or sets the name of the application associated with the connection string. + The name of the application, or ".NET SqlClient Data Provider" if no name has been supplied. + + and assigns a connection string in the object's constructor. The code displays the parsed and recreated version of the connection string, and then modifies the property of the object. Finally, the code displays the new connection string, including the new key/value pair. + + [!code-csharp[SqlConnectionStringBuilder.ApplicationName#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_ApplicationName.cs#1)] + + The sample displays the following text in the console window: + +``` +Original: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True +ApplicationName=".Net SqlClient Data Provider" +Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True;Application Name="My Application" +``` + + ]]> + + To set the value to null, use . + + + Gets or sets a Boolean value that indicates whether asynchronous processing is allowed by the connection created by using this connection string. + The value of the property, or if no value has been supplied. + + object, this key/value pair must be included within the connection string of the associated object. + + + +## Examples + The following example retrieves a connection string and verifies that the connection string is configured to allow for asynchronous processing. (In this case, the string comes from a procedure within the application, but in a production application, the connection string might come from a configuration file, or some other source.) Then, the example performs an asynchronous operation, updating values within a sample database on a background thread. + + [!code-csharp[SqlConnectionStringBuilder_AsynchronousProcessing#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_AsynchronousProcessing.cs#1)] + + ]]> + + + + + + + Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database. + The value of the property, or if no value has been supplied. + + instance, and sets the `AttachDBFilename` property in order to specify the name of an attached data file. + + [!code-csharp[DataWorks SqlConnectionStringBuilder_AttachDBFilename#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs#1)] + + ]]> + + To set the value to null, use . + Working with Connection Strings + ADO.NET Overview + + + Gets the authentication of the connection string. + The authentication of the connection string. + To be added. + + + Clears the contents of the instance. + + method removes all key/value pairs from the , and resets all corresponding properties. This includes setting the property to 0, and setting the property to an empty string. + + + +## Examples + The following example demonstrates calling the method. This example populates the with some key/value pairs, and then calls the method and shows the results. + + [!code-csharp[DataWorks SqlConnectionStringBuilder_Clear#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_Clear.cs#1)] + + ]]> + + + + Gets or sets the column encryption settings for the connection string builder. + The column encryption settings for the connection string builder. + To be added. + + + Obsolete. Gets or sets a Boolean value that indicates whether the connection is reset when drawn from the connection pool. + The value of the property, or true if no value has been supplied. + + connection string, which has been removed from version 3.5 SP1 of the .NET Framework. + + ]]> + + + + The number of reconnections attempted after identifying that there was an idle connection failure. This must be an integer between 0 and 255. Default is 1. Set to 0 to disable reconnecting on idle connection failures. An will be thrown if set to a value outside of the allowed range. + The number of reconnections attempted after identifying that there was an idle connection failure. + + + Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure. This must be an integer between 1 and 60. The default is 10 seconds. An will be thrown if set to a value outside of the allowed range. + Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure. + + + Gets or sets the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. + The value of the property, or 15 seconds if no value has been supplied. + + property, and then displays the new connection string. + + [!code-csharp[SqlConnectionStringBuilder_ConnectTimeout#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs#1)] + + ]]> + + + + The key to locate in the . + Determines whether the contains a specific key. + true if the contains an element that has the specified key; otherwise, false. + + contains a fixed-size collection of key/value pairs, the method determines only if a particular key name is valid. + + + +## Examples + The following example creates a instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the **ContainsKey** method. + + [!code-csharp[SqlConnectionStringBuilder_ContainsKey#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_ContainsKey.cs#1)] + + The example displays the following output in the console window: + +``` +Connection string = Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True +True +True +True +False +``` + + ]]> + + + is null ( in Visual Basic) + + + Gets or sets a value that indicates whether a client/server or in-process connection to SQL Server should be made. + The value of the property, or if none has been supplied. + + [!NOTE] +> The property returns `null` if the connection string for the is "context connection=true". + + ]]> + + + + Gets or sets the SQL Server Language record name. + The value of the property, or if no value has been supplied. + + + + To set the value to null, use . + + + Gets or sets the name or network address of the instance of SQL Server to connect to. + The value of the property, or if none has been supplied. + + class converts synonyms for the "Data Source" connection string key into the well-known key: + + [!code-csharp[SqlConnectionStringBuilder_DataSource#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_DataSource.cs#1)] + + ]]> + + To set the value to null, use . + + + Gets or sets the enclave attestation Url to be used with enclave based Always Encrypted. + The enclave attestation Url. + To be added. + + + Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed. + The value of the property, or if none has been supplied. + + + + Working with Connection Strings + ADO.NET Overview + + + Gets or sets a Boolean value that indicates whether the SQL Server connection pooler automatically enlists the connection in the creation thread's current transaction context. + The value of the property, or if none has been supplied. + + + + + + Gets or sets the name or address of the partner server to connect to if the primary server is down. + The value of the property, or if none has been supplied. + To be added. + To set the value to null, use . + + + To be added. + To be added. + To be added. + + + Gets or sets the name of the database associated with the connection. + The value of the property, or if none has been supplied. + + class to add the name of the database to the connection string. The code displays the contents of the property, just to verify that the class was able to convert from the synonym ("Database") to the appropriate property value. + + [!code-csharp[SqlConnectionStringBuilder_InitialCatalog#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs#1)] + + ]]> + + To set the value to null, use . + + + Gets or sets a Boolean value that indicates whether User ID and Password are specified in the connection (when ) or whether the current Windows account credentials are used for authentication (when ). + The value of the property, or if none has been supplied. + + 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-csharp[SqlConnectionStringBuilder_IntegratedSecurity#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs#1)] + + ]]> + + + + Gets a value that indicates whether the has a fixed size. + + in every case, because the supplies a fixed-size collection of key/value pairs. + To be added. + Working with Connection Strings + ADO.NET Overview + + + The key of the item to get or set. + Gets or sets the value associated with the specified key. In C#, this property is the indexer. + The value associated with the specified key. + + contains a fixed-size dictionary, trying to add a key that does not exist within the dictionary throws a . + + + +## Examples + The following code, in a console application, creates a new and adds key/value pairs to its connection string, using the property. + + [!code-csharp[SqlConnectionStringBuilder2#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder2.cs#1)] + + ]]> + + + is a null reference ( in Visual Basic). + Tried to add a key that does not exist within the available keys. + Invalid value within the connection string (specifically, a Boolean or numeric value was expected but not supplied). + + + Gets an that contains the keys in the . + An that contains the keys in the . + + 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. + + [!code-csharp[SqlConnectionStringBuilder_Keys#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_Keys.cs#1)] + + ]]> + + + + + + Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed. + The value of the property, or 0 if none has been supplied. + + + + + + Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string. + The value of the property, or 100 if none has been supplied. + + + + + + Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string. + The value of the property, or 0 if none has been supplied. + + + + + + When true, an application can maintain multiple active result sets (MARS). When false, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection. + + For more information, see [Multiple Active Result Sets (MARS)](https://msdn.microsoft.com//library/cfa084cz.aspx). + The value of the property, or if none has been supplied. + + + + + + If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover=true provides faster detection of and connection to the (currently) active server. For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](~/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md). + Returns indicating the current value of the property. + To be added. + + + Gets or sets a string that contains the name of the network library used to establish a connection to the SQL Server. + The value of the property, or if none has been supplied. + + + + To set the value to null, use . + + + Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server. + The value of the property, or 8000 if none has been supplied. + + + + + + Gets or sets the password for the SQL Server account. + The value of the property, or if none has been supplied. + + has not been set and you retrieve the value, the return value is . To reset the password for the connection string, pass null to the Item property. + + + +## Examples + The following example shows how to set . + + [!code-csharp[SqlConnectionStringBuilder_Password#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_Password.cs#1)] + + ]]> + + The password was incorrectly set to null. See code sample below. + + + Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. + The value of the property, or if none has been supplied. + + + + + + The blocking period behavior for a connection pool. + The available blocking period settings. + + enumeration for available settings. + + ]]> + + + + Gets or sets a Boolean value that indicates whether the connection will be pooled or explicitly opened every time that the connection is requested. + The value of the property, or if none has been supplied. + + + + + + The key of the key/value pair to be removed from the connection string in this . + Removes the entry with the specified key from the instance. + + if the key existed within the connection string and was removed; if the key did not exist. + + instance. Because the maintains a fixed-size collection of key/value pairs, calling the method simply 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| +|---------|-------------------| +|Application Name|".Net SqlClient Data Provider"| +|Asynchronous Processing|False| +|AttachDBFilename|Empty string| +|Connection Timeout|15| +|Context Connection|False| +|Current Language|Empty string| +|Data Source|Empty string| +|Encrypt|False| +|Enlist|True| +|Failover Partner|Empty string| +|Initial Catalog|Empty string| +|Integrated Security|False| +|Load Balance Timeout|0| +|Max Pool Size|100| +|Min Pool Size|0| +|MultipleActiveResultSets|False| +|Network Library|Empty string| +|Packet Size|8000| +|Password|Empty string| +|Persist Security Info|False| +|Pooling|True| +|Replication|False| +|Transaction Binding|Implicit Unbind| +|User ID|Empty string| +|User Instance|False| +|Workstation ID|Empty string| + + + +## 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-csharp[SqlConnectionStringBuilder_Remove#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_Remove.cs#1)] + + The example displays the following text in the console window: + +``` +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 +``` + + ]]> + + + is null ( in Visual Basic) + + + Gets or sets a Boolean value that indicates whether replication is supported using the connection. + The value of the property, or false if none has been supplied. + + + + + + The key to locate in the . + Indicates whether the specified key exists in this instance. + + if the contains an entry with the specified key; otherwise, . + + method. + + ]]> + + + + Gets or sets a string value that indicates how the connection maintains its association with an enlisted transaction. + The value of the property, or if none has been supplied. + + control how a binds to an enlisted . + + The following table shows the possible values for the property: + +|Value|Description| +|-----------|-----------------| +|Implicit Unbind|The default. Causes the connection to detach from the transaction when it ends. After detaching, additional requests on the connection are performed in autocommit mode. The property is not checked when executing requests while the transaction is active. After the transaction has ended, additional requests are performed in autocommit mode.| +|Explicit Unbind|Causes the connection to remain attached to the transaction until the connection is closed or until is called with a `null` (`Nothing` in Visual Basic) value. An is thrown if is not the enlisted transaction or if the enlisted transaction is not active. This behavior enforces the strict scoping rules required for support.| + + ]]> + + + + When the value of this key is set to , the application is required to retrieve all IP addresses for a particular DNS entry and attempt to connect with the first one in the list. If the connection is not established within 0.5 seconds, the application will try to connect to all others in parallel. When the first answers, the application will establish the connection with the respondent IP address. + A boolean value. + + + + + + Gets or sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust. + A . Recognized values are , , , and . + + + + + + The key of the item to retrieve. + The value corresponding to . + Retrieves a value corresponding to the supplied key from this . + + if was found within the connection string; otherwise, . + + method lets developers safely retrieve a value from a without needing to verify that the supplied key name is a valid key name. Because **TryGetValue** does not raise an exception when you call it, passing in a nonexistent key, you do not have to look for a key before retrieving its value. Calling **TryGetValue** with a nonexistent key will place the value null (`Nothing` in Visual Basic) in the `value` parameter. + + + +## Examples + The following example demonstrates the behavior of the **TryGetValue** method. + + [!code-csharp[SqlConnectionStringBuilder_TryGetValue#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_TryGetValue.cs#1)] + + The sample displays the following results: + +``` +Data Source=(local) +Trusted_Connection=True +Unable to retrieve value for 'InvalidKey' +Unable to retrieve value for null key. +``` + + ]]> + + + contains a null value ( in Visual Basic). + + + Gets or sets a string value that indicates the type system the application expects. + The following table shows the possible values for the property: + + Value + + Description + + SQL Server 2005 + + Uses the SQL Server 2005 type system. No conversions are made for the current version of ADO.NET. + + SQL Server 2008 + + Uses the SQL Server 2008 type system. + + Latest + + Use the latest version than this client-server pair can handle. This will automatically move forward as the client and server components are upgraded. + + + + + + + + Gets or sets the user ID to be used when connecting to SQL Server. + The value of the property, or if none has been supplied. + + + + To set the value to null, use . + + + Gets or sets a value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller. + The value of the property, or if none has been supplied. + + [!NOTE] +> This feature is available only with the SQL Server Express Edition. For more information on user instances, see [SQL Server Express User Instances](~/docs/framework/data/adonet/sql/sql-server-express-user-instances.md). + + ]]> + + To set the value to null, use . + + + Gets an that contains the values in the . + An that contains the values in the . + + is unspecified, but it is the same order as the associated keys in the returned by the property. Because each instance of the always contains the same fixed set of keys, the property always returns the values corresponding to the fixed set of keys, in the same order as the keys. + + + +## Examples + The following example first creates a new , and then iterates through all the values within the object. + + [!code-csharp[SqlConnectionStringBuilder_Values#1](~/sqlclient/doc/samples/SqlConnectionStringBuilder_Values.cs#1)] + + ]]> + + + + + Gets or sets the name of the workstation connecting to SQL Server. + The value of the property, or if none has been supplied. + + + + To set the value to null, use . + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml new file mode 100644 index 0000000000..2b65e81146 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml @@ -0,0 +1,88 @@ + + + + + + provides a more secure way to specify the password for a login attempt using SQL Server Authentication. + + is comprised of a user id and a password that will be used for SQL Server Authentication. The password in a object is of type . + + cannot be inherited. + + Windows Authentication () remains the most secure way to log in to a SQL Server database. + + to get or set a connection's object. Use to change the password for a object. For information on how a object affects connection pool behavior, see [SQL Server Connection Pooling (ADO.NET)](~/docs/framework/data/adonet/sql-server-connection-pooling.md). + + An exception will be raised if a non-null object is used in a connection with any of the following connection string keywords: + +- `Integrated Security = true` + +- `Password` + +- `User ID` + +- `Context Connection = true` + + The following sample connects to a SQL Server database using : + +``` +// change connection string in the APP.CONFIG file + + + + +// then use the following snippet: +using System.Configuration; + +System.Windows.Controls.TextBox txtUserId = new System.Windows.Controls.TextBox(); +System.Windows.Controls.PasswordBox txtPwd = new System.Windows.Controls.PasswordBox(); + +Configuration config = Configuration.WebConfigurationManager.OpenWebConfiguration(Null); +ConnectionStringSettings connString = config.ConnectionStrings.ConnectionString["MyConnString"]; + +using (SqlConnection conn = new SqlConnection(connString.ConnectionString)) +{ +SecureString pwd = txtPwd.SecurePassword; +pwd.MakeReadOnly(); +SqlCredential cred = new SqlCredential(txtUserId.Text, pwd); +conn.Credential = cred; +conn.Open(); +``` + + ]]> + + + + The user id. + To be added. + The password; a value marked as read-only. Passing a read/write parameter will raise an . + Creates an object of type . + + value is allowed. An attempt to pass a null parameter in the constructor will raise an exception. + + ]]> + + ADO.NET Overview + + + Gets the password component of the object. + The password component of the object. + To be added. + ADO.NET Overview + + + Gets the user ID component of the object. + The user ID component of the object. + To be added. + ADO.NET Overview + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml new file mode 100644 index 0000000000..77b67143e8 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml @@ -0,0 +1,501 @@ + + + + + Represents a set of data commands and a database connection that are used to fill the and update a SQL Server database. This class cannot be inherited. + + , serves as a bridge between a and SQL Server for retrieving and saving data. The provides this bridge by mapping , which changes the data in the to match the data in the data source, and , which changes the data in the data source to match the data in the , using the appropriate Transact-SQL statements against the data source. The update is performed on a by-row basis. For every inserted, modified, and deleted row, the method determines the type of change that has been performed on it (`Insert`, `Update`, or `Delete`). Depending on the type of change, the `Insert`, `Update`, or `Delete` command template executes to propagate the modified row to the data source. When the fills a , it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the property is set to . You may also have the create the schema of the , including primary key information, before filling it with data using `FillSchema`. For more information, see [Adding Existing Constraints to a DataSet](~/docs/framework/data/adonet/adding-existing-constraints-to-a-dataset.md). + + is used in conjunction with and to increase performance when connecting to a SQL Server database. + +> [!NOTE] +> If you are using SQL Server stored procedures to edit or delete data using a `DataAdapter`, make sure that you do not use SET NOCOUNT ON in the stored procedure definition. This causes the rows affected count returned to be zero, which the `DataAdapter` interprets as a concurrency conflict. In this event, a will be thrown. + + The also includes the , , , , and properties to facilitate the loading and updating of data. + + When an instance of is created, the read/write properties are set to initial values. For a list of these values, see the constructor. + + The , , and are generic templates that are automatically filled with individual values from every modified row through the parameters mechanism. + + For every column that you propagate to the data source on , a parameter should be added to the `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The property of the object should be set to the name of the column. This setting indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row. + +> [!NOTE] +> An will occur if the method is called and the table contains a user-defined type that is not available on the client computer. For more information, see [CLR User-Defined Types](/sql/relational-databases/clr-integration-database-objects-user-defined-types/clr-user-defined-types). + + + +## Examples + The following example uses the , , and to select records from a database and populate a with the selected rows. The filled is then returned. To accomplish this, the method is passed an initialized , a connection string, and a query string that is a Transact-SQL SELECT statement. + + [!code-csharp[SqlDataAdapter_SelectCommand Example#1](~/sqlclient/doc/samples/SqlDataAdapter_SelectCommand.cs#1)] + + ]]> + + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + + is created, the following read/write properties are set to the following initial values. + +|Properties|Initial value| +|----------------|-------------------| +||`MissingMappingAction.Passthrough`| +||`MissingSchemaAction.Add`| + + You can change the value of any of these properties through a separate call to the property. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlDataAdapter.SqlDataAdapter Example#1](~/sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter.cs#1)] + + ]]> + + + + A that is a Transact-SQL SELECT statement or stored procedure and is set as the property of the . + Initializes a new instance of the class with the specified as the property. + + constructor sets the property to the value specified in the `selectCommand` parameter. + + When an instance of is created, the following read/write properties are set to the following initial values. + +|Properties|Initial value| +|----------------|-------------------| +||`MissingMappingAction.Passthrough`| +||`MissingSchemaAction.Add`| + + You can change the value of any of these properties through a separate call to the property. + + When (or any of the other command properties) is assigned to a previously created , the is not cloned. The maintains a reference to the previously created object. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlDataAdapter_SqlDataAdapter1 Example#1](~/sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs#1)] + + ]]> + + + + A that is a Transact-SQL SELECT statement or stored procedure to be used by the property of the . + A that represents the connection. If your connection string does not use , you can use to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string. + Initializes a new instance of the class with a and a object. + + opens and closes a if it is not already open. This can be useful in an application that must call the method for two or more objects. If the is already open, you must explicitly call **Close** or **Dispose** to close it. + + When an instance of is created, the following read/write properties are set to the following initial values. + +|Properties|Initial value| +|----------------|-------------------| +||`MissingMappingAction.Passthrough`| +||`MissingSchemaAction.Add`| + + You can change the value of either of these properties through a separate call to the property. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlDataAdapter_SqlDataAdapter3 Example#1](~/sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs#1)] + + ]]> + + + + A that is a Transact-SQL SELECT statement or stored procedure to be used by the property of the . + The connection string. If your connection string does not use , you can use and to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string. + Initializes a new instance of the class with a and a connection string. + + constructor uses the `selectCommandText` parameter to set the property. The will create and maintain the connection created with the `selectConnectionString` parameter. + + When an instance of is created, the following read/write properties are set to the following initial values. + +|Properties|Initial value| +|----------------|-------------------| +||`MissingMappingAction.Passthrough`| +||`MissingSchemaAction.Add`| + + You can change the value of any of these properties through a separate call to the property. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlDataAdapter_SqlDataAdapter2 Example#1](~/sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs#1)] + + ]]> + + + + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + To be added. + To be added. + To be added. + + + Gets or sets a Transact-SQL statement or stored procedure to delete records from the data set. + A used during to delete records in the database that correspond to deleted rows in the . + + , if this property is not set and primary key information is present in the , the can be generated automatically if you set the property and use the . Then, any additional commands that you do not set are generated by the . This generation logic requires key column information to be present in the . For more information, see [Generating Commands with CommandBuilders](~/docs/framework/data/adonet/generating-commands-with-commandbuilders.md). + + When is assigned to a previously created , the is not cloned. The maintains a reference to the previously created object. + + For every column that you propagate to the data source on , a parameter should be added to the `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row. + + + +## Examples + The following example creates a and sets the , , , and properties. It assumes you have already created a object. + + [!code-csharp[SqlDataAdapter#1](~/sqlclient/doc/samples/SqlDataAdapter.cs#1)] + + ]]> + + + + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + + + Gets or sets a Transact-SQL statement or stored procedure to insert new records into the data source. + A used during to insert records into the database that correspond to new rows in the . + + , if this property is not set and primary key information is present in the , the can be generated automatically if you set the property and use the . Then, any additional commands that you do not set are generated by the . This generation logic requires key column information to be present in the . For more information, see [Generating Commands with CommandBuilders](~/docs/framework/data/adonet/generating-commands-with-commandbuilders.md). + + When is assigned to a previously created , the is not cloned. The maintains a reference to the previously created object. + + If execution of this command returns rows, these rows can be added to the depending on how you set the **UpdatedRowSource** property of the object. + + For every column that you propagate to the data source on , a parameter should be added to `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row. + + + +## Examples + The following example creates a and sets the , , , and properties. It assumes you have already created a object. + + [!code-csharp[SqlDataAdapter#1](~/sqlclient/doc/samples/SqlDataAdapter.cs#1)] + + ]]> + + + + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + + + Occurs during after a command is executed against the data source. The attempt to update is made, so the event fires. + + , there are two events that occur per data row updated. The order of execution is as follows: + +1. The values in the are moved to the parameter values. + +2. The event is raised. + +3. The command executes. + +4. If the command is set to `FirstReturnedRecord`, the first returned result is placed in the . + +5. If there are output parameters, they are placed in the . + +6. The event is raised. + +7. is called. + + + +## Examples + The following example shows how to use both the and events. + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0) + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0) + + [!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)] + + ]]> + + + + Occurs during before a command is executed against the data source. The attempt to update is made, so the event fires. + + , there are two events that occur per data row updated. The order of execution is as follows: + +1. The values in the are moved to the parameter values. + +2. The event is raised. + +3. The command executes. + +4. If the command is set to `FirstReturnedRecord`, the first returned result is placed in the . + +5. If there are output parameters, they are placed in the . + +6. The event is raised. + +7. is called. + + + +## Examples + The following example shows how to use both the and events. + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0) + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0) + + [!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)] + + ]]> + + + + Gets or sets a Transact-SQL statement or stored procedure used to select records in the data source. + A used during to select records from the database for placement in the . + + is assigned to a previously created , the is not cloned. The maintains a reference to the previously created object. + + If the does not return any rows, no tables are added to the , and no exception is raised. + + + +## Examples + The following example creates a and sets the , , , and properties. It assumes you have already created a object. + + [!code-csharp[SqlDataAdapter#1](~/sqlclient/doc/samples/SqlDataAdapter.cs#1)] + + ]]> + + + + For a description of this member, see . + An that is used during to delete records in the data source for deleted rows in the data set. + + instance is cast to an interface. + + ]]> + + + + For a description of this member, see . + An that is used during to insert records in the data source for new rows in the data set. + + instance is cast to an interface. + + ]]> + + + + For a description of this member, see . + An that is used during to select records from data source for placement in the data set. + + instance is cast to an interface. + + ]]> + + + + For a description of this member, see . + An that is used during to update records in the data source for modified rows in the data set. + + instance is cast to an interface. + + ]]> + + + + For a description of this member, see . + A new object that is a copy of the current instance. + + instance is cast to an interface. + + ]]> + + + + To be added. + To be added. + + + Gets or sets the number of rows that are processed in each round-trip to the server. + The number of rows to process per-batch. + + Value is + + Effect + + 0 + + There is no limit on the batch size. + + 1 + + Disables batch updating. + + >1 + + Changes are sent using batches of operations at a time. + + + + When setting this to a value other than 1, all the commands associated with the have to have their **UpdatedRowSource** property set to or . An exception is thrown otherwise. + + property to update a data source with changes from a . This can increase application performance by reducing the number of round-trips to the server. + + Executing an extremely large batch could decrease performance. Therefore, you should test for the optimum batch size setting before implementing your application. + + An is thrown if the value is set to a number less than zero. + + ]]> + + + + Gets or sets a Transact-SQL statement or stored procedure used to update records in the data source. + A used during to update records in the database that correspond to modified rows in the . + + , if this property is not set and primary key information is present in the , the can be generated automatically if you set the property and use the . Then, any additional commands that you do not set are generated by the . This generation logic requires key column information to be present in the . For more information, see [Generating Commands with CommandBuilders](~/docs/framework/data/adonet/generating-commands-with-commandbuilders.md). + + When is assigned to a previously created , the is not cloned. The maintains a reference to the previously created object. + +> [!NOTE] +> If execution of this command returns rows, the updated rows may be merged with the depending on how you set the **UpdatedRowSource** property of the object. + + For every column that you propagate to the data source on , a parameter should be added to `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. + + The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but taken from the particular column in the currently processed row. + + + +## Examples + The following example creates a and sets the , , and properties. It assumes you have already created a object. + + [!code-csharp[SqlDataAdapter#1](~/sqlclient/doc/samples/SqlDataAdapter.cs#1)] + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml new file mode 100644 index 0000000000..0e59c70bc2 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml @@ -0,0 +1,1212 @@ + + + + + Provides a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited. + + , you must call the method of the object, instead of directly using a constructor. + + While the is being used, the associated is busy serving the , and no other operations can be performed on the other than closing it. This is the case until the method of the is called. For example, you cannot retrieve output parameters until after you call . + + Changes made to a result set by another process or thread while data is being read may be visible to the user of the `SqlDataReader`. However, the precise behavior is timing dependent. + + and are the only properties that you can call after the is closed. Although the property may be accessed while the exists, always call before returning the value of to guarantee an accurate return value. + + When using sequential access (), an will be raised if the position is advanced and another read operation is attempted on the previous column. + +> [!NOTE] +> For optimal performance, avoids creating unnecessary objects or making unnecessary copies of data. Therefore, multiple calls to methods such as return a reference to the same object. Use caution if you are modifying the underlying value of the objects returned by methods such as . + + + +## Examples + The following example creates a , a , and a . The example reads through the data, writing it out to the console window. The code then closes the . The is closed automatically at the end of the `using` code block. + + [!code-csharp[SqlDataReader_Read Example#1](~/sqlclient/doc/samples/SqlDataReader_Read.cs#1)] + + ]]> + + + + Closes the object. + + method when you are through using the to use the associated for any other purpose. + + The `Close` method fills in the values for output parameters, return values and `RecordsAffected`, increasing the time that it takes to close a `SqlDataReader` that was used to process a large or complex query. When the return values and the number of records affected by a query are not significant, the time that it takes to close the `SqlDataReader` can be reduced by calling the method of the associated object before calling the `Close` method. + +> [!CAUTION] +> Do not call `Close` or `Dispose` on a Connection, a DataReader, or any other managed object in the `Finalize` method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](~/docs/standard/garbage-collection/index.md). + + + +## Examples + The following example creates a , a `SqlCommand`, and a . The example reads through the data, writing it out to the console window. The code then closes the . The is closed automatically at the end of the `using` code block. + + [!code-csharp[SqlDataReader_Close Example#1](~/sqlclient/doc/samples/SqlDataReader_Close.cs#1)] + + ]]> + + + + Gets the associated with the . + The associated with the . + To be added. + + + Gets a value that indicates the depth of nesting for the current row. + The depth of nesting for the current row. + + + + + + To be added. + To be added. + To be added. + + + Gets the number of columns in the current row. + When not positioned in a valid recordset, 0; otherwise the number of columns in the current row. The default is -1. + + to 0. However. this should not be confused with a query that returns 0 rows (such as SELECT * FROM *table* WHERE 1 = 2) in which case returns the number of columns in the table, including hidden fields. Use to exclude hidden fields. + + ]]> + + There is no current connection to an instance of SQL Server. + + + The zero-based column ordinal. + Gets the value of the specified column as a Boolean. + The value of the column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a byte. + The value of the specified column as a byte. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + The index within the field from which to begin the read operation. + The buffer into which to read the stream of bytes. + The index within the where the write operation is to start. + The maximum length to copy into the buffer. + Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. + The actual number of bytes read. + + returns the number of available bytes in the field. Most of the time this is the exact length of the field. However, the number returned may be less than the true length of the field if `GetBytes` has already been used to obtain bytes from the field. This may be the case, for example, if the is reading a large data structure into a buffer. For more information, see the `SequentialAccess` setting for . + + If you pass a buffer that is `null`, returns the length of the entire field in bytes, not the remaining size based on the buffer offset parameter. + + No conversions are performed; therefore, the data retrieved must already be a byte array. + + ]]> + + + + The zero-based column ordinal. + Gets the value of the specified column as a single character. + The value of the specified column. + + . + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + The index within the field from which to begin the read operation. + The buffer into which to read the stream of bytes. + The index within the where the write operation is to start. + The maximum length to copy into the buffer. + Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. + The actual number of characters read. + + returns the number of available characters in the field. Frequently this is the exact length of the field. However, the number returned may be less than the true length of the field if `GetChars` has already been used to obtain characters from the field. This may be the case, for example, if the is reading a large data structure into a buffer. For more information, see the `SequentialAccess` setting for . + + The actual number of characters read can be less than the requested length, if the end of the field is reached. If you pass a buffer that is `null`, returns the length of the entire field in characters, not the remaining size based on the buffer offset parameter. + + No conversions are performed; therefore. the data retrieved must already be a character array. + +> [!NOTE] +> The method returns 0 when `dataIndex` is negative. + + ]]> + + + + To be added. + To be added. + To be added. + + + A column ordinal. + Returns an for the specified column ordinal. + The instance for the specified column ordinal. + To be added. + + + The zero-based ordinal position of the column to find. + Gets a string representing the data type of the specified column. + The string representing the data type of the specified column. + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a object. + The value of the specified column. + + object. + + Call to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Retrieves the value of the specified column as a object. + The value of the specified column. + + object. + + Call to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a object. + The value of the specified column. + + object. + + Call to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a double-precision floating point number. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + Returns an that iterates through the . + An for the . + + + + + + The zero-based column ordinal. + Gets the that is the data type of the object. + The that is the data type of the object. If the type does not exist on the client, in the case of a User-Defined Type (UDT) returned from the database, **GetFieldType** returns null. + To be added. + + + The type of the value to be returned. + The column to be retrieved. + Synchronously gets the value of the specified column as a type. is the asynchronous version of this method. + The returned type object. + + .||| + + For more information, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Tried to read a previously-read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + Trying to read a column that does not exist. + The value of the column was null ( == ), retrieving a non-SQL type. + + doesn't match the type returned by SQL Server or cannot be cast. + + + The type of the value to be returned. + The column to be retrieved. + The cancellation instruction, which propagates a notification that operations should be canceled. This does not guarantee the cancellation. A setting of makes this method equivalent to . The returned task must be marked as cancelled. + Asynchronously gets the value of the specified column as a type. is the synchronous version of this method. + The returned type object. + + .||| + + For more information, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Tried to read a previously-read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + + is specified in the connection string. + Trying to read a column that does not exist. + The value of the column was null ( == ), retrieving a non-SQL type. + + doesn't match the type returned by SQL Server or cannot be cast. + + + The zero-based column ordinal. + Gets the value of the specified column as a single-precision floating point number. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a globally unique identifier (GUID). + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a 16-bit signed integer. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a 32-bit signed integer. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column as a 64-bit signed integer. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the name of the specified column. + The name of the specified column. + To be added. + + + The name of the column. + Gets the column ordinal, given the name of the column. + The zero-based column ordinal. + + method. + + [!code-csharp[SqlDataReader_GetOrdinal#1](~/sqlclient/doc/samples/SqlDataReader_GetOrdinal.cs#1)] + + ]]> + + The name specified is not a valid column name. + + + An representing the column ordinal. + Gets an that is a representation of the underlying provider-specific field type. + Gets an that is a representation of the underlying provider-specific field type. + To be added. + + + An representing the column ordinal. + Gets an that is a representation of the underlying provider specific value. + An that is a representation of the underlying provider specific value. + To be added. + + + An array of into which to copy the column values. + Gets an array of objects that are a representation of the underlying provider specific values. + The array of objects that are a representation of the underlying provider specific values. + To be added. + + + Returns a that describes the column metadata of the . + A that describes the column metadata. + + method returns metadata about each column in the following order: + +|DataReader column|Description| +|-----------------------|-----------------| +|AllowDBNull|Set if the consumer can set the column to a null value or if the provider cannot determine whether the consumer can set the column to a null value. Otherwise, not set. A column may contain null values, even if it cannot be set to a null value.| +|BaseCatalogName|The name of the catalog in the data store that contains the column. NULL if the base catalog name cannot be determined. The default of this column is a null value.| +|BaseColumnName|The name of the column in the data store. This might be different than the column name returned in the ColumnName column if an alias was used. A null value if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the data store. The default of this column is a null value.| +|BaseSchemaName|The name of the schema in the data store that contains the column. A null value if the base schema name cannot be determined. The default of this column is a null value.| +|BaseServerName|The name of the instance of Microsoft SQL Server used by the .| +|BaseTableName|The name of the table or view in the data store that contains the column. A null value if the base table name cannot be determined. The default of this column is a null value.| +|ColumnName|The name of the column; this might not be unique. If this cannot be determined, a null value is returned. This name always reflects the most recent renaming of the column in the current view or command text.| +|ColumnOrdinal|The zero-based ordinal of the column. This column cannot contain a null value.| +|ColumnSize|The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type. For `nvarchar(MAX)`, `varchar(MAX)`, and `varbinary(MAX)` columns stored in a SQL Server database, the maximum size is 2GB. If these columns are stored and accessed as files, the limit on maximum size is imposed by the file system. This value changes when using the `Type System Version` keyword in the connection string. For new types they are represented as downlevel types. The MAX data types return the normal 4k for `nvarchar` and 8000 for `varchar`. For more information, see the [Transact-SQL reference](/sql/t-sql/language-reference).| +|DataTypeName|Returns a string representing the data type of the specified column.| +|IsAliased|`true`: The column name is an alias.

`false`: The column name is not an alias.| +|IsAutoIncrement|`true`: The column assigns values to new rows in fixed increments.

`false`: The column does not assign values to new rows in fixed increments. The default of this column is `false`.| +|IsColumnSet|`true`: The column is a sparse column that is a member of a column set.| +|IsExpression|`true`: The column is an expression.

`false`: The column is not an expression.| +|IsHidden|`true`: The column is hidden.

`false`: The column is not hidden.| +|IsIdentity|`true`: The column is an identity column.

`false`: The column is not an identity column.| +|IsKey|`true`: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with `IsKey` set to `true` must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index.

`false`: The column is not required to uniquely identify the row.| +|IsLong|`true`: The column contains a Binary Long Object (BLOB) that contains very long data. The definition of very long data is provider-specific.

`false`: The column does not contain a Binary Long Object (BLOB) that contains very long data.| +|IsReadOnly|`true`: The column cannot be modified.

`false`: The column can be modified.| +|IsRowVersion|`true`: The column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.

`false`: The column does not contain a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.| +|IsUnique|`true`: Column is of type `timestamp`.

`false`: Column is not of type `timestamp`.| +|NonVersionedProviderType|The type of the column irrespective of the current `Type System Version` specified in the connection string. The returned value is from the enumeration.| +|NumericPrecision|If `ProviderType` is a numeric data type, this is the maximum precision of the column. The precision depends on the definition of the column. If `ProviderType` is not a numeric data type, this is 255.| +|NumericScale|If `ProviderType` is DBTYPE_DECIMAL or DBTYPE_NUMERIC, the number of digits to the right of the decimal point. Otherwise, this is 255.| +|ProviderSpecificDataType|Returns the provider-specific data type of the column based on the `Type System Version` keyword in the connection string.| +|ProviderType|The indicator of the column's data type. If the data type of the column varies from row to row, this must be Object. This column cannot contain a null value.| +|UdtAssemblyQualifiedName|If the column is a user-defined type (UDT), this is the qualified name of the UDT's assembly as per . If the column is not a UDT, this is null.| +|XmlSchemaCollectionDatabase|The name of the database where the schema collection for this XML instance is located, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case the `XmlSchemaCollectionName` and `XmlSchemaCollectionOwningSchema` columns are also null.| +|XmlSchemaCollectionName|The name of the schema collection for this XML instance, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if there is no associated schema collection. If the value is null, the `XmlSchemaCollectionDatabase` and `XmlSchemaCollectionOwningSchema` columns are also null.| +|XmlSchemaCollectionOwningSchema|The owning relational schema where the schema collection for this XML instance is located, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case the `XmlSchemaCollectionDatabase` and `XmlSchemaCollectionName` columns are also null.| + +> [!NOTE] +> To make sure that metadata columns return the correct information, you must call with the `behavior` parameter set to `KeyInfo`. Otherwise, some of the columns in the schema table may return default, null, or incorrect data. + + ]]>
+
+ The is closed. +
+ + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column. + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as . + The value of the column expressed as a . + To be added. + + + The zero-based column ordinal. + Gets the value of the specified column as . + The value of the column expressed as a . + To be added. + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Gets the value of the specified column as a . + The value of the column expressed as a . + + + + + + The zero-based column ordinal. + Returns the data value in the specified column as a SQL Server type. + The value of the column expressed as a . + + returns data using the native SQL Server types. To retrieve data using the .NET Framework types, see . + + ]]> + + + + An array of into which to copy the values. The column values are expressed as SQL Server types. + Fills an array of that contains the values for all the columns in the record, expressed as SQL Server types. + An integer indicating the number of columns copied. + + array does not need to match the number of columns in the record. You can pass an array that contains fewer than the number of columns contained in the record. Only the amount of data the array holds is copied to the array, starting at the column with ordinal 0. You can also pass an array whose length is more than the number of columns contained in the resulting row. Any remaining columns are untouched. + + ]]> + + + is null. + + + The zero-based column ordinal. + Gets the value of the specified column as an XML value. + A value that contains the XML stored within the corresponding field. + + to check for null values before calling this method. + + ]]> + + The index passed was outside the range of 0 to - 1 + An attempt was made to read or access columns in a closed . + The retrieved data is not compatible with the type. + + + The zero-based column ordinal. + Retrieves binary, image, varbinary, UDT, and variant data types as a . + A stream object. + + defaults to the value of ; but you can modify via . + + Null values will be returned as an empty (zero bytes) . + + will raise an exception when used on an object returned by when is in effect. + + exceptions raised from are thrown as exceptions; check the inner exception for the . + + The following members are not available for objects returned by : + +- BeginWrite + +- EndWrite + +- Length + +- Position + +- Seek + +- SetLength + +- Write + +- WriteByte + +- WriteTimeout + + When the connection property `ContextConnection=true`, only supports synchronous data retrieval for both sequential () and non-sequential () access. + + For more information, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Tried to read a previously-read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + Trying to read a column that does not exist. + The returned type was not one of the types below: + +- binary + +- image + +- varbinary + +- udt + + + The zero-based column ordinal. + Gets the value of the specified column as a string. + The value of the specified column. + + to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The column to be retrieved. + Retrieves Char, NChar, NText, NVarChar, text, varChar, and Variant data types as a . + The returned object. + + exceptions raised from are thrown as exceptions; check the inner exception for the . + + Null values will be returned as an empty (zero bytes) . + + will raise an exception when used on an object returned by when is in effect. + + When the connection property `ContextConnection=true`, only supports synchronous data retrieval for both sequential () and non-sequential () access. + + For more information, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Tried to read a previously-read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + Trying to read a column that does not exist. + The returned type was not one of the types below: + +- char + +- nchar + +- ntext + +- nvarchar + +- text + +- varchar + + + The zero-based column ordinal. + Retrieves the value of the specified column as a object. + The value of the specified column. + + object. + + Call to check for null values before calling this method. + + ]]> + + The specified cast is not valid. + + + The zero-based column ordinal. + Gets the value of the specified column in its native format. + This method returns for null database columns. + + returns data using the .NET Framework types. + + ]]> + + + + An array of into which to copy the attribute columns. + Populates an array of objects with the column values of the current row. + The number of instances of in the array. + + array that contains fewer than the number of columns contained in the resulting row. Only the amount of data the array holds is copied to the array. You can also pass an array whose length is more than the number of columns contained in the resulting row. + + This method returns for null database columns. + + + +## Examples + The following example demonstrates using a correctly sized array to read all values from the current row in the supplied . In addition, the sample demonstrates using a fixed-sized array that could be either smaller or larger than the number of available columns. + + [!code-csharp[DataTableReader_GetValues#2](~/sqlclient/doc/samples/DataTableReader_GetValues.cs#2)] + + ]]> + + + + The value of the specified column. + Retrieves data of type XML as an . + The returned object. + + object returned by does not support asynchronous operations. If you require asynchronous operations on an , cast the XML column to an NVARCHAR(MAX) on the server and use with . + + exceptions raised from are thrown as exceptions; check the inner exception for the . + + will raise an exception when used on an object returned by when is in effect. + + For more information, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Trying to read a previously read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + Trying to read a column that does not exist. + The returned type was not xml. + + + Gets a value that indicates whether the contains one or more rows. + + if the contains one or more rows; otherwise . + To be added. + + + Retrieves a Boolean value that indicates whether the specified instance has been closed. + + if the specified instance is closed; otherwise . + + instance that is closed. + + ]]> + + + + A enumeration. + Determines whether the specified matches that of the . + + if the specified is true, otherwise. + + + + + + The zero-based column ordinal. + Gets a value that indicates whether the column contains non-existent or missing values. + + if the specified column value is equivalent to ; otherwise . + + , , and so on) to avoid raising an error. + + [!code-csharp[SqlDataReader_IsDBNull#1](~/sqlclient/doc/samples/SqlDataReader_IsDBNull.cs#1)] + + ]]> + + + + The zero-based column to be retrieved. + The cancellation instruction, which propagates a notification that operations should be canceled. This does not guarantee the cancellation. A setting of makes this method equivalent to . The returned task must be marked as cancelled. + An asynchronous version of , which gets a value that indicates whether the column contains non-existent or missing values. + + The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object. + + if the specified column value is equivalent to otherwise . + + + + The connection drops or is closed during the data retrieval. + + The is closed during the data retrieval. + + There is no data ready to be read (for example, the first hasn't been called, or returned false). + + Trying to read a previously read column in sequential mode. + + There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream. + + is specified in the connection string. + Trying to read a column that does not exist. + + + Gets the value of a column in its native format. + + + The zero-based column ordinal. + Gets the value of the specified column in its native format given the column ordinal. + The value of the specified column in its native format. + To be added. + The index passed was outside the range of 0 through . + + + The column name. + Gets the value of the specified column in its native format given the column name. + The value of the specified column in its native format. + + + + No column with the specified name was found. + + + Advances the data reader to the next result, when reading the results of batch Transact-SQL statements. + + if there are more result sets; otherwise . + + + + + + The cancellation instruction. + An asynchronous version of , which advances the data reader to the next result, when reading the results of batch [!INCLUDE[tsql](~/includes/tsql-md.md)] statements. + + The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object. + A task representing the asynchronous operation. + + + + Calling more than once for the same instance before task completion. + + is specified in the connection string. + SQL Server returned an error while executing the command text. + + + Advances the to the next record. + + if there are more rows; otherwise . + + is before the first record. Therefore, you must call to begin accessing any data. + + Only one `SqlDataReader` per associated may be open at a time, and any attempt to open another will fail until the first one is closed. Similarly, while the `SqlDataReader` is being used, the associated `SqlConnection` is busy serving it until you call . + + + +## Examples + The following example creates a , a , and a . The example reads through the data, writing it out to the console window. The code then closes the . The is closed automatically at the end of the `using` code block. + + [!code-csharp[SqlDataReader_Read Example#1](~/sqlclient/doc/samples/SqlDataReader_Read.cs#1)] + + ]]> + + SQL Server returned an error while executing the command text. + + + The cancellation instruction. + An asynchronous version of , which advances the to the next record. + + The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object. + A task representing the asynchronous operation. + + is set to `Default`, reads the entire row before returning the Task. + + For more information, including code samples, about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](~/docs/framework/data/adonet/asynchronous-programming.md). + + ]]> + + Calling more than once for the same instance before task completion. + + is specified in the connection string. + SQL Server returned an error while executing the command text. + + + Gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement. + The number of rows changed, inserted, or deleted; 0 if no rows were affected or the statement failed; and -1 for SELECT statements. + + and are the only properties that you can call after the is closed. + + ]]> + + + + Returns an enumerator that can be used to iterate through the item collection. + The enumerator that can be used to iterate through the item collection. + To be added. + + + A column ordinal. + Returns an for the specified column ordinal. + The instance for the specified column ordinal. + + instance is cast to an interface. + + ]]> + + + + Releases all resources that are used by the data reader. + To be added. + + + Gets the number of fields in the that are not hidden. + The number of fields that are not hidden. + + are visible. For example, a SELECT on a partial primary key returns the remaining parts of the key as hidden fields. The hidden fields are always appended behind the visible fields. + + ]]> + + +
+
\ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml new file mode 100644 index 0000000000..7c9cc88cf0 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml @@ -0,0 +1,257 @@ + + + + + The object represents a query notification dependency between an application and an instance of SQL Server. An application can create a object and register to receive notifications via the event handler. + + is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. allows you to receive notifications when the original data in the database changes so that the cache can be refreshed. + + To set up a dependency, you need to associate a object to one or more objects. To receive notifications, you need to subscribe to the event. For more information about the requirements for creating queries for notifications, see [Working with Query Notifications](/sql/relational-databases/native-client/features/working-with-query-notifications). + +> [!NOTE] +> was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have objects set up for a single database server. If you are developing an application where you need reliable sub-second notifications when data changes, review the sections [Planning an Efficient Query Notifications Strategy](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v=sql.105)#planning-an-efficient-query-notifications-strategy) and [Alternatives to Query Notifications](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v=sql.105)#alternatives-to-query-notifications) in the [Planning for Notifications](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v%3dsql.105)) article. + + For more information, see [Query Notifications in SQL Server](~/docs/framework/data/adonet/sql/query-notifications-in-sql-server.md) and [Building Notification Solutions](https://docs.microsoft.com/previous-versions/sql/sql-server-2005/ms171065(v%3dsql.90)). + +> [!NOTE] +> The event may be generated on a different thread from the thread that initiated command execution. + + Query notifications are supported only for SELECT statements that meet a list of specific requirements. + + ]]> + + + + Creates a new instance of the class. + + + Creates a new instance of the class with the default settings. + + object using the default Service Broker service name and time-out. At some point after construction, you must use the method to associate one or more commands to this object. + + Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications). + ]]> + + + + The object to associate with this object. The constructor will set up a object and bind it to the command. + Creates a new instance of the class and associates it with the parameter. + + class, and binds it to a object. + + Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications). + + ]]> + + The parameter is NULL. + The object already has a object assigned to its property, and that is not associated with this dependency. + + + The object to associate with this object. The constructor sets up a object and bind it to the command. + The notification request options to be used by this dependency. to use the default service. + The time-out for this notification in seconds. The default is 0, indicating that the server's time-out should be used. + Creates a new instance of the class, associates it with the parameter, and specifies notification options and a time-out value. + + + + The parameter is NULL. + The time-out value is less than zero. + The object already has a object assigned to its property and that is not associated with this dependency. + + An attempt was made to create a **SqlDependency** instance from within SQLCLR. + + + A object containing a statement that is valid for notifications. + Associates a object with this instance. + + + + The parameter is null. + The object already has a object assigned to its property, and that is not associated with this dependency. + + + Gets a value that indicates whether one of the result sets associated with the dependency has changed. + A Boolean value indicating whether one of the result sets has changed. + + event, you can check the property to determine if the query results have changed. + + The property does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate a change event. + + ]]> + + + + Gets a value that uniquely identifies this instance of the class. + A string representation of a GUID that is generated for each instance of the class. + + property is used to uniquely identify a given instance. + + ]]> + + + + Occurs when a notification is received for any of the commands associated with this object. + + occurs when the results for the associated command change. If you are not using , you can check the property to determine whether the query results have changed. + + The event does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate . + + ]]> + + + + Starts the listener for receiving dependency change notifications. + + listener will restart when an error occurs in the SQL Server connection. + + Multiple calls to the method can be made, subject to the following restrictions: + +- Multiple calls with identical parameters (the same connection string and Windows credentials in the calling thread) are valid. + +- Multiple calls with different connection strings are valid as long as: + + - Each connection string specifies a different database, or + + - Each connection string specifies a different user, or + + - The calls come from different application domains. + + You can make the work correctly for applications that use multiple threads to represent different user credentials without giving the dbo role to the group, because different users can subscribe and listen (using or ) to a notification queue created by an administrator. When the relevant application domain starts, call Start with the (Windows) credentials of a user that has permission to initialize a service/queue (the CREATE QUEUE and CREATE SERVICE permissions for the database). Ensure that Start is only called once per AppDomain, otherwise an ambiguity exception is raised. The user thread must have permission to subscribe to the notification (the SUBSCRIBE QUERY NOTIFICATIONS permission for the database). will associate the subscription request of a non-administrator user to the service/queue created by the administrator. + + ]]> + + + + The connection string for the instance of SQL Server from which to obtain change notifications. + Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string. + + if the listener initialized successfully; if a compatible listener already exists. + + for receiving dependency notifications from the instance of SQL Server specified by the `connectionString` parameter. This method may be called more than once with different connection strings for multiple servers. + + For additional remarks, see . + + ]]> + + The parameter is NULL. + The parameter is the same as a previous call to this method, but the parameters are different. + + The method was called from within the CLR. + The caller does not have the required code access security (CAS) permission. + A subsequent call to the method has been made with an equivalent parameter with a different user, or a user that does not default to the same schema. + + Also, any underlying **SqlClient** exceptions. + + + + The connection string for the instance of SQL Server from which to obtain change notifications. + An existing SQL Server Service Broker queue to be used. If , the default queue is used. + Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string using the specified SQL Server Service Broker queue. + + if the listener initialized successfully; if a compatible listener already exists. + + for receiving dependency notifications from the instance of SQL Server specified by the `connectionString` parameter. This method may be called more than once with different connection strings for multiple servers. + + If no queue name is specified, creates a temporary queue and service in the server that is used for the entire process, even if the process involves more than one . The queue and service are automatically removed upon application shutdown. + + For additional remarks, see . + + ]]> + + The parameter is NULL. + The parameter is the same as a previous call to this method, but the parameters are different. + + The method was called from within the CLR. + The caller does not have the required code access security (CAS) permission. + A subsequent call to the method has been made with an equivalent parameter but a different user, or a user that does not default to the same schema. + + Also, any underlying **SqlClient** exceptions. + + + + Stops a listener for a connection specified in a previous call. + + listener will restart when an error occurs in the SQL Server connection. + + ]]> + + + + Connection string for the instance of SQL Server that was used in a previous call. + Stops a listener for a connection specified in a previous call. + + if the listener was completely stopped; if the was unbound from the listener, but there are is at least one other using the same listener. + + method must be called for each call. A given listener only shuts down fully when it receives the same number of requests as requests. + + ]]> + + The parameter is NULL. + The method was called from within SQLCLR. + The caller does not have the required code access security (CAS) permission. + An underlying **SqlClient** exception occurred. + + + Connection string for the instance of SQL Server that was used in a previous call. + The SQL Server Service Broker queue that was used in a previous call. + Stops a listener for a connection specified in a previous call. + + if the listener was completely stopped; if the was unbound from the listener, but there is at least one other using the same listener. + + method must be called for each call. A given listener only shuts down fully when it receives the same number of requests as requests. + + ]]> + + The parameter is NULL. + The method was called from within SQLCLR. + The caller does not have the required code access security (CAS) permission. + And underlying **SqlClient** exception occurred. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml new file mode 100644 index 0000000000..36192bec3f --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml @@ -0,0 +1,33 @@ + + + + + Encapsulates the information SqlClient sends to SQL Server to initiate the process of attesting and creating a secure session with the enclave, SQL Server uses for computations on columns protected using Always Encrypted. + To be added. + + + The enclave attestation protocol. + The input of the enclave attestation protocol. + A Diffie-Hellman algorithm that encapsulates a client-side key pair. + Initializes a new instance of the class. + To be added. + + is . + + + Gets a Diffie-Hellman algorithm that encapsulates a key pair that SqlClient uses to establish a secure session with the enclave. + The Diffie-Hellman algorithm. + To be added. + + + Gets the information used to initiate the process of attesting the enclave. The format and the content of this information is specific to the attestation protocol. + The information required by SQL Server to execute attestation protocol identified by EnclaveAttestationProtocols. + To be added. + + + Gets the enclave attestation protocol identifier. + The enclave attestation protocol identifier. + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml new file mode 100644 index 0000000000..918ad0ab81 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml @@ -0,0 +1,29 @@ + + + + + Encapsulates the state of a secure session between SqlClient and an enclave inside SQL Server, which can be used for computations on encrypted columns protected with Always Encrypted. + To be added. + + + The symmetric key used to encrypt all the information sent using the session. + The session ID. + Instantiates a new instance of the class. + To be added. + + is . + + has zero length. + + + Gets the symmetric key that SqlClient uses to encrypt all the information it sends to the enclave using the session. + The symmetric key. + To be added. + + + Gets the session ID. + The session ID. + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml new file mode 100644 index 0000000000..24cf205e4b --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml @@ -0,0 +1,207 @@ + + + + + Collects information relevant to a warning or error returned by SQL Server. + + is created and managed by the , which in turn is created by the class. + + Messages with a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement. + + The remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server usually closes the . However, the user can reopen the connection and continue. In both cases, a is generated by the method executing the command. + + For more information on errors generated by SQL Server, see [Cause and Resolution of Database Engine Errors](https://msdn.microsoft.com/library/ms365262.aspx). For more information about severity levels, see [Database Engine Error Severities](https://msdn.microsoft.com/library/ms164086.aspx). + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + + + + + Gets the severity level of the error returned from SQL Server. + A value from 1 to 25 that indicates the severity level of the error. The default is 0. + + remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server usually closes the . However, the user can reopen the connection and continue. In both cases, a is generated by the method executing the command. + + For more information on errors generated by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError_State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets the line number within the Transact-SQL command batch or stored procedure that contains the error. + The line number within the Transact-SQL command batch or stored procedure that contains the error. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets the text describing the error. + The text describing the error. For more information on errors generated by SQL Server, see Database Engine Events and Errors. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets a number that identifies the type of error. + The number that identifies the type of error. + +
This number corresponds to an entry in the `master.dbo.sysmessages` table.|Typically greater than 0|No| +|Connection timeout|-2|0|Yes (Number = 258)| +|Communication error (non-LocalDB)|Win32 error code|0|Yes (Number = Win32 error code)| +|Communication error (LocalDB)|Win32 error code|0|No| +|Encryption capability mismatch|20|0|No| +|Failed to start LocalDB|Win32 error code|0|No| +|Read-only routing failure|0|0|No| +|Server had severe error processing query|0|0|No| +|Processed cancellation while parsing results|0|0|No| +|Failed to create user instance|0|0|No| + + For more information on errors generated by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]>
+
+
+ + Gets the name of the stored procedure or remote procedure call (RPC) that generated the error. + The name of the stored procedure or RPC. For more information on errors generated by SQL Server, see Database Engine Events and Errors. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets the name of the instance of SQL Server that generated the error. + The name of the instance of SQL Server. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets the name of the provider that generated the error. + The name of the provider that generated the error. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Some error messages can be raised at multiple points in the code for the Database Engine. For example, an 1105 error can be raised for several different conditions. Each specific condition that raises an error assigns a unique state code. + The state code. + + within the collection. + + [!code-csharp[SqlError.State Example#1](~/sqlclient/doc/samples/SqlError_State.cs#1)] + + ]]> + + + + Gets the complete text of the error message. + The complete text of the error. + + , and the stack trace. For example: + + SqlError:UserId or Password not valid. \ + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + +
+
\ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml new file mode 100644 index 0000000000..68e08cae0b --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml @@ -0,0 +1,114 @@ + + + + + Collects all errors generated by the .NET Framework Data Provider for SQL Server. This class cannot be inherited. + + to collect instances of the class. always contains at least one instance of the class. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + + + + + Copies the elements of the collection. + + + The to copy elements into. + The index from which to start copying into the parameter. + Copies the elements of the collection into an , starting at the specified index. + To be added. + The sum of and the number of elements in the collection is greater than the of the . + The is . + The is not valid for . + + + The to copy the elements into. + The index from which to start copying into the parameter. + Copies the elements of the collection into a , starting at the specified index. + To be added. + The sum of and the number of elements in the collection is greater than the length of the . + The is . + The is not valid for . + + + Gets the number of errors in the collection. + The total number of errors in the collection. + + within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + + + Returns an enumerator that iterates through the . + An for the . + + + + + + The zero-based index of the error to retrieve. + Gets the error at the specified index. + A that contains the error at the specified index. + + within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + Index parameter is outside array bounds. + + + + For a description of this member, see . + + if access to the is synchronized (thread safe); otherwise, . + + instance is cast to an interface. + + ]]> + + + + For a description of this member, see . + An object that can be used to synchronize access to the . + + instance is cast to an interface. + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml new file mode 100644 index 0000000000..63849e6dfc --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml @@ -0,0 +1,367 @@ + + + + + The exception that is thrown when SQL Server returns a warning or error. This class cannot be inherited. + + always contains at least one instance of . + + Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement. + + The remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the . However, the user can reopen the connection and continue. In both cases, a is generated by the method executing the command. + + For information about the warning and informational messages sent by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). The class maps to SQL Server severity. + + The following is general information on handling exceptions. Your code should catch exceptions to prevent the application from crashing and to allow displaying a relevant error message to the user. You can use database transactions to ensure that the data is consistent regardless of what happens in the client application (including a crash). Features like System.Transaction.TransactionScope or the BeginTransaction method (in System.Data.OleDb.OleDbConnection, System.Data.ODBC.ODBCConnection, and Microsoft.Data.SqlClient.SqlConnection) ensure consistent data regardless of exceptions raised by a provider. Transactions can fail, so catch failures and retry the transaction. + + Note that beginning with .NET Framework 4.5, can return an inner . + + The exception class of a .NET Framework data provider reports provider-specific errors. For example System.Data.Odbc has OdbcException, System.Data.OleDb has OleDbException, and Microsoft.Data.SqlClient has SqlException. For the best level of error detail, catch these exceptions and use the members of these exception classes to get details of the error. + + In addition to the provider-specific errors, .NET Framework data provider types can raise .NET Framework exceptions such as System.OutOfMemoryException and System.Threading.ThreadAbortException. Recovery from these exceptions may not be possible. + + Bad input can cause a .NET Framework data provider type to raise an exception such as System.ArgumentException or System.IndexOutOfRangeException. Calling a method at the wrong time can raise System.InvalidOperationException. + + So, in general, write an exception handler that catches any provider specific exceptions as well as exceptions from the common language runtime. These can be layered as follows: + +```csharp +try { + // code here +} +catch (SqlException odbcEx) { + // Handle more specific SqlException exception here. +} +catch (Exception ex) { + // Handle generic ones here. +} + +``` + + Or: + +```csharp +try { + // code here +} +catch (Exception ex) { + if (ex is SqlException) { + // Handle more specific SqlException exception here. + } + else { + // Handle generic ones here. + } +} + +``` + + It is also possible for a .NET Framework data provider method call to fail on a thread pool thread with no user code on the stack. In this case, and when using asynchronous method calls, you must register the event to handle those exceptions and avoid application crash. + + + +## Examples + The following example generates a and then displays the exception. + + [!code-csharp[SqlException_Errors1 Example#1](~/sqlclient/doc/samples/SqlException_Errors1.cs#1)] + + ]]> + + + + + + Gets the severity level of the error returned from the .NET Framework Data Provider for SQL Server. + A value from 1 to 25 that indicates the severity level of the error. + + remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the . However, the user can reopen the connection and continue. In both cases, a is generated by the method executing the command. + + For information about the warning and informational messages sent by SQL Server, see the Troubleshooting section of the SQL Server documentation. + + This is a wrapper for the property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Represents the client connection ID. For more information, see Data Tracing in ADO.NET. + The client connection ID. + + . + + ]]> + + + + Gets a collection of one or more objects that give detailed information about exceptions generated by the .NET Framework Data Provider for SQL Server. + The collected instances of the class. + + class always contains at least one instance of the class. + + This is a wrapper for . For more information on SQL Server engine errors, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlError_ToString Example#1](~/sqlclient/doc/samples/SqlError_ToString.cs#1)] + + ]]> + + + + + + The that holds the serialized object data about the exception being thrown. + The that contains contextual information about the source or destination. + Sets the with information about the exception. + + + + The parameter is a null reference ( in Visual Basic). + + + Gets the line number within the Transact-SQL command batch or stored procedure that generated the error. + The line number within the Transact-SQL command batch or stored procedure that generated the error. + + property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Gets the text describing the error. + The text describing the error. + To be added. + + + Gets a number that identifies the type of error. + The number that identifies the type of error. + + property of the first in the property. For more information on SQL Server engine errors, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Gets the name of the stored procedure or remote procedure call (RPC) that generated the error. + The name of the stored procedure or RPC. + + property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Gets the name of the computer that is running an instance of SQL Server that generated the error. + The name of the computer running an instance of SQL Server. + + property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Gets the name of the provider that generated the error. + The name of the provider that generated the error. + + property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Gets a numeric error code from SQL Server that represents an error, warning or "no data found" message. For more information about how to decode these values, see Database Engine Events and Errors. + The number representing the error code. + + property of the first in the property. + + + +## Examples + The following example displays each within the collection. + + [!code-csharp[SqlException_Errors2 Example#1](~/sqlclient/doc/samples/SqlException_Errors2.cs#1)] + + ]]> + + + + + + + + + + Returns a string that represents the current object, and includes the client connection ID (for more information, see ). + A string that represents the current object.. + + , which includes the client connection ID: + +```csharp +using Microsoft.Data.SqlClient; +using System; + +public class A { + public static void Main() { + SqlConnection connection = new SqlConnection(); + connection.ConnectionString = "Data Source=a_valid_server;Initial Catalog=Northwinda;Integrated Security=true"; + try { + connection.Open(); + } + catch (SqlException p) { + Console.WriteLine("{0}", p.ClientConnectionId); + Console.WriteLine("{0}", p.ToString()); + } + connection.Close(); + } +} +``` + + The following Visual Basic sample is functionally equivalent to the previous (C#) sample: + +```vb +Imports Microsoft.Data.SqlClient +Imports System + +Module Module1 + + Sub Main() + Dim connection As New SqlConnection() + connection.ConnectionString = "Data Source=a_valid_server;Initial Catalog=Northwinda;Integrated Security=true" + Try + connection.Open() + Catch p As SqlException + Console.WriteLine("{0}", p.ClientConnectionId) + Console.WriteLine("{0}", p.ToString()) + End Try + connection.Close() + End Sub + +End Module +``` + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml new file mode 100644 index 0000000000..dc949e9e27 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml @@ -0,0 +1,52 @@ + + + + + Provides data for the event. + + event contains a collection which contains the warnings sent from the server. + + An event is generated when a SQL Server message with a severity level of 10 or less occurs. + + ]]> + + + + Gets the collection of warnings sent from the server. + The collection of warnings sent from the server. + To be added. + + + Gets the full text of the error sent from the database. + The full text of the error. + + property of the first in the collection. + + ]]> + + + + Gets the name of the object that generated the error. + The name of the object that generated the error. + + property of the first in the collection. + + ]]> + + + + Retrieves a string representation of the event. + A string representing the event. + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml new file mode 100644 index 0000000000..c6c980f0e9 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml @@ -0,0 +1,18 @@ + + + + + The source of the event. + A object that contains the event data. + Represents the method that will handle the event of a . + + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](~/docs/standard/events/index.md). + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml new file mode 100644 index 0000000000..659e412468 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml @@ -0,0 +1,41 @@ + + + + + Represents the set of arguments passed to the notification event handler. + To be added. + + + + value that indicates whether this notification is generated because of an actual change, or by the subscription. + + value that indicates the reason for the notification event. This may occur because the data in the store actually changed, or the notification became invalid (for example, it timed out). + + value that indicates the source that generated the notification. + Creates a new instance of the object. + To be added. + + + Gets a value that indicates the reason for the notification event, such as a row in the database being modified or a table being truncated. + The notification event reason. + + + + + + Gets a value that indicates the source that generated the notification, such as a change to the query data or the database's state. + The source of the notification. + To be added. + + + Gets a value that indicates whether this notification is generated because of an actual change, or by the subscription. + A value indicating whether the notification was generated by a change or a subscription. + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml new file mode 100644 index 0000000000..fb7c491731 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml @@ -0,0 +1,73 @@ + + + + + This enumeration provides additional information about the different notifications that can be received by the dependency event handler. + + enumeration is referenced by an instance of the class. + + ]]> + + + + The object already fired, and new commands cannot be added to it. + + + An underlying server object related to the query was modified. + + + Data was changed by a DELETE statement. + + + An underlying object related to the query was dropped. + + + An internal server error occurred. + + + The object has expired. + + + Data was changed by an INSERT statement. + + + A statement was provided that cannot be notified (for example, an UPDATE statement). + + + The statement was executed under an isolation mode that was not valid (for example, Snapshot). + + + Used to distinguish the server-side cause for a query notification firing. + + + The SET options were not set appropriately at subscription time. + + + A previous statement has caused query notifications to fire under the current transaction. + + + A SELECT statement that cannot be notified or was provided. + + + Fires as a result of server resource pressure. + + + The server was restarted (notifications are sent during restart.). + + + The subscribing query causes the number of templates on one of the target tables to exceed the maximum allowable limit. + + + One or more tables were truncated. + + + Used when the info option sent by the server was not recognized by the client. + + + Data was changed by an UPDATE statement. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml new file mode 100644 index 0000000000..35d6f64cf5 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml @@ -0,0 +1,51 @@ + + + + + Indicates the source of the notification received by the dependency event handler. + + class. + + Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications). + + ]]> + + + + A client-initiated notification occurred, such as a client-side time-out or as a result of attempting to add a command to a dependency that has already fired. + + + Data has changed; for example, an insert, update, delete, or truncate operation occurred. + + + The database state changed; for example, the database related to the query was dropped or detached. + + + The run-time environment was not compatible with notifications; for example, the isolation level was set to snapshot, or one or more SET options are not compatible. + + + A run-time error occurred during execution. + + + A database object changed; for example, an underlying object related to the query was dropped or modified. + + + Internal only; not intended to be used in your code. + + + The Transact-SQL statement is not valid for notifications; for example, a SELECT statement that could not be notified or a non-SELECT statement was executed. + + + A system-related event occurred. For example, there was an internal error, the server was restarted, or resource pressure caused the invalidation. + + + The subscription time-out expired. + + + Used when the source option sent by the server was not recognized by the client. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml new file mode 100644 index 0000000000..38025201f6 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml @@ -0,0 +1,25 @@ + + + + + Describes the different notification types that can be received by an event handler through the parameter. + + enumeration is referenced by an instance of the class. This information is provided when a notification event is fired with the class. + + ]]> + + + + Data on the server being monitored changed. Use the item to determine the details of the change. + + + There was a failure to create a notification subscription. Use the object's item to determine the cause of the failure. + + + Used when the type option sent by the server was not recognized by the client. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml new file mode 100644 index 0000000000..165ed733a4 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml @@ -0,0 +1,653 @@ + + + + + Represents a parameter to a and optionally its mapping to columns. This class cannot be inherited. For more information on parameters, see [Configuring Parameters and Parameter Data Types](~/docs/framework/data/adonet/configuring-parameters-and-parameter-data-types.md). + + [!NOTE] +> Nameless, also called ordinal, parameters are not supported by the .NET Framework Data Provider for SQL Server. + + For more information, along with additional sample code demonstrating how to use parameters, see [Commands and Parameters](~/docs/framework/data/adonet/commands-and-parameters.md). + + + +## Examples + The following example creates multiple instances of through the collection within the . These parameters are used to select data from the data source and put the data in the . This example assumes that a and a have already been created by using the appropriate schema, commands, and connection. For more information and additional examples on using parameters, see [Retrieving and Modifying Data in ADO.NET](~/docs/framework/data/adonet/retrieving-and-modifying-data.md) and [Configuring Parameters and Parameter Data Types](~/docs/framework/data/adonet/configuring-parameters-and-parameter-data-types.md). + + [!code-csharp[SqlParameterCollection_Add6](~/sqlclient/doc/samples/SqlParameterCollection_Add6.cs#1)] + + ]]> + + + + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + + and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter.cs#1)] + + ]]> + + + + The name of the parameter to map. + One of the values. + Initializes a new instance of the class that uses the parameter name and the data type. + + are inferred from the value of the `dbType` parameter. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter2 Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter2.cs#1)] + + ]]> + + The value supplied in the parameter is an invalid back-end data type. + + + The name of the parameter to map. + An that is the value of the . + Initializes a new instance of the class that uses the parameter name and a value of the new . + + in the `value` parameter, the is inferred from the Microsoft .NET Framework type of the . + + Use caution when you use this overload of the constructor to specify integer parameter values. Because this overload takes a `value` of type , you must convert the integral value to an type when the value is zero, as the following C# example demonstrates. + +```csharp +Parameter = new SqlParameter("@pname", (object)0); +``` + +If you do not perform this conversion, the compiler assumes that you are trying to call the constructor overload. + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter6 Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter6.cs#1)] + + ]]> + + + + The name of the parameter to map. + One of the values. + The length of the parameter. + Initializes a new instance of the class that uses the parameter name, the , and the size. + + and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter4 Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter4.cs#1)] + + ]]> + + The value supplied in the parameter is an invalid back-end data type. + + + The name of the parameter to map. + One of the values. + The length of the parameter. + The name of the source column () if this is used in a call to . + Initializes a new instance of the class that uses the parameter name, the , the size, and the source column name. + + and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter5 Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter5.cs#1)] + + ]]> + + The value supplied in the parameter is an invalid back-end data type. + + + The name of the parameter to map. + One of the values. + The length of the parameter. + One of the values. + + if the value of the field can be null; otherwise, . + The total number of digits to the left and right of the decimal point to which is resolved. + The total number of decimal places to which is resolved. + The name of the source column () if this is used in a call to . + One of the values. + An that is the value of the . + Initializes a new instance of the class that uses the parameter name, the type of the parameter, the size of the parameter, a , the precision of the parameter, the scale of the parameter, the source column, a to use, and the value of the parameter. + + are inferred from the value of the `dbType` parameter if they are not explicitly set in the `size` and `precision` parameters. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_SqlParameter1 Example#1](~/sqlclient/doc/samples/SqlParameter_SqlParameter1.cs#1)] + + ]]> + + The value supplied in the parameter is an invalid back-end data type. + + + The name of the parameter to map. + One of the values. + The length of the parameter. + One of the values. + The total number of digits to the left and right of the decimal point to which is resolved. + The total number of decimal places to which is resolved. + The name of the source column () if this is used in a call to . + One of the values. + + if the source column is nullable; if it is not. + An that is the value of the . + The name of the database where the schema collection for this XML instance is located. + The owning relational schema where the schema collection for this XML instance is located. + The name of the schema collection for this parameter. + Initializes a new instance of the class that uses the parameter name, the type of the parameter, the length of the parameter the direction, the precision, the scale, the name of the source column, one of the values, a Boolean for source column mapping, the value of the , the name of the database where the schema collection for this XML instance is located, the owning relational schema where the schema collection for this XML instance is located, and the name of the schema collection for this parameter. + + and are inferred from the value of the `dbType` parameter if they are not explicitly set in the `size` and `precision` parameters. + + ]]> + + + + Gets or sets the object that defines how string comparisons should be performed for this parameter. + A object that defines string comparison for this parameter. + To be added. + + + Gets or sets the of the parameter. + One of the values. The default is . + + and are linked. Therefore, setting the changes the to a supporting . + + For a list of the supported data types, see the appropriate member. For more information, see [DataAdapter Parameters](~/docs/framework/data/adonet/dataadapter-parameters.md). + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_IsNullable Example#1](~/sqlclient/doc/samples/SqlParameter_IsNullable.cs#1)] + + ]]> + + + + Gets or sets a value that indicates whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter. + One of the values. The default is . + + is output, and execution of the associated does not return a value, the contains a null value. + + `Output`, `InputOut`, and `ReturnValue` parameters returned by calling cannot be accessed until you close the . + + + +## Examples + The following example creates a and sets some of its properties. + + [Commands and Parameters](~/docs/framework/data/adonet/commands-and-parameters.md) + + [DataAdapter Parameters](~/docs/framework/data/adonet/dataadapter-parameters.md) + + [SQL Server and ADO.NET](~/docs/framework/data/adonet/sql/index.md) + + ]]> + + The property was not set to one of the valid values. + + + Enforces encryption of a parameter when using Always Encrypted. If SQL Server informs the driver that the parameter does not need to be encrypted, the query using the parameter will fail. This property provides additional protection against security attacks that involve a compromised SQL Server providing incorrect encryption metadata to the client, which may lead to data disclosure. + + if the parameter has a force column encryption; otherwise, . + To be added. + + + Gets or sets a value that indicates whether the parameter accepts null values. is not used to validate the parameter's value and will not prevent sending or receiving a null value when executing a command. + + if null values are accepted; otherwise, . The default is . + + class. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#2](~/sqlclient/doc/samples/SqlParameter.cs#2)] + + ]]> + + + + Gets or sets the locale identifier that determines conventions and language for a particular region. + The locale identifier associated with the parameter. + + property. + +```csharp +static void CreateSqlParameterLocaleId(){ + SqlParameter parameter = new SqlParameter("pName", SqlDbType.VarChar); + parameter.LocaleId = 1033; // English - United States +} +``` + + ]]> + + + + Gets or sets the offset to the property. + The offset to the . The default is 0. + + and sets some of its properties. + + [!code-csharp[SqlParameter#3](~/sqlclient/doc/samples/SqlParameter.cs#3)] + + ]]> + + + + Gets or sets the name of the . + The name of the . The default is an empty string. + + is specified in the form @paramname. You must set before executing a that relies on parameters. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_ParameterName Example#1](~/sqlclient/doc/samples/SqlParameter_ParameterName.cs#1)] + + ]]> + + + + Gets or sets the maximum number of digits used to represent the property. + The maximum number of digits used to represent the property. The default value is 0. This indicates that the data provider sets the precision for . + + property is used by parameters that have a of `Decimal`. + + You do not need to specify values for the and properties for input parameters, as they can be inferred from the parameter value. `Precision` and `Scale` are required for output parameters and for scenarios where you need to specify complete metadata for a parameter without indicating a value, such as specifying a null value with a specific precision and scale. + +> [!NOTE] +> Use of this property to coerce data passed to the database is not supported. To round, truncate, or otherwise coerce data before passing it to the database, use the class that is part of the `System` namespace prior to assigning a value to the parameter's `Value` property. + +> [!NOTE] +> Microsoft .NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the or of parameter values. This can cause truncated data being inserted at the data source. If you are using .NET Framework version 1.0, validate the and of values before setting the parameter value. When you use .NET Framework version 1.1 or a later version, an exception is thrown if a parameter value is set with an invalid . values that exceed the parameter scale are still truncated. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter_Precision Example#1](~/sqlclient/doc/samples/SqlParameter_Precision.cs#1)] + + ]]> + + + + Resets the type associated with this . + + and properties of the . + + ]]> + + + + Resets the type associated with this . + + and properties of the . + + ]]> + + + + Gets or sets the number of decimal places to which is resolved. + The number of decimal places to which is resolved. The default is 0. + + property is used by parameters that have a of `Decimal`. + +> [!WARNING] +> Data may be truncated if the property is not explicitly specified and the data on the server does not fit in scale 0 (the default). + + You do not need to specify values for the and properties for input parameters, as they can be inferred from the parameter value. `Precision` and `Scale` are required for output parameters and for scenarios where you need to specify complete metadata for a parameter without indicating a value, such as specifying a null value with a specific precision and scale. + +> [!NOTE] +> Use of this property to coerce data passed to the database is not supported. To round, truncate, or otherwise coerce data before passing it to the database, use the class that is part of the `System` namespace prior to assigning a value to the parameter's `Value` property. + +> [!NOTE] +> .NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the or of parameter values. This can cause truncated data to be inserted at the data source. If you are using .NET Framework version 1.0, validate the and of values before setting the parameter value. values that exceed the parameter scale are still truncated. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#4](~/sqlclient/doc/samples/SqlParameter.cs#4)] + + ]]> + + + + Gets or sets the maximum size, in bytes, of the data within the column. + The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value. + + . For character types, the size specified with is in characters. + + The property is used for binary and string types. For parameters of type `SqlType.String`, `Size` means length in Unicode characters. For parameters of type `SqlType.Xml`, `Size` is ignored. + + For nonstring data types and ANSI string data, the property refers to the number of bytes. For Unicode string data, refers to the number of characters. The count for strings does not include the terminating character. + + For variable-length data types, describes the maximum amount of data to transmit to the server. For example, for a Unicode string value, could be used to limit the amount of data sent to the server to the first one hundred characters. + + If not explicitly set, the size is inferred from the actual size of the specified parameter value. + + If the fractional part of the parameter value is greater than the size, then the value will be truncated to match the size. + + For fixed length data types, the value of is ignored. It can be retrieved for informational purposes, and returns the maximum amount of bytes the provider uses when transmitting the value of the parameter to the server. + + For information about streaming, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#5](~/sqlclient/doc/samples/SqlParameter.cs#5)] + + ]]> + + + + Gets or sets the name of the source column mapped to the and used for loading or returning the + The name of the source column mapped to the . The default is an empty string. + + is set to anything other than an empty string, the value of the parameter is retrieved from the column with the name. If is set to `Input`, the value is taken from the . If is set to `Output`, the value is taken from the data source. A of `InputOutput` is a combination of both. + + For more information about how to use the property, see [DataAdapter Parameters](~/docs/framework/data/adonet/dataadapter-parameters.md) and [Updating Data Sources with DataAdapters](~/docs/framework/data/adonet/updating-data-sources-with-dataadapters.md). + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#6](~/sqlclient/doc/samples/SqlParameter.cs#6)] + + ]]> + + + + Sets or gets a value which indicates whether the source column is nullable. This allows to correctly generate Update statements for nullable columns. + + if the source column is nullable; if it is not. + + is used by the to correctly generate update commands when dealing with nullable columns. Generally, use of is limited to developers inheriting from . + + uses this property to determine whether the source column is nullable, and sets this property to `true` if it is nullable, and `false` if it is not. When is generating its Update statement, it examines the for each parameter. If the property is `true`, generates a WHERE clauses like the following (in this query expression, "FieldName" represents the name of the field): + +``` +((@IsNull_FieldName = 1 AND FieldName IS NULL) OR + (FieldName = @Original_FieldName)) +``` + + If for the field is false, generates the following WHERE clause: + +``` +FieldName = @OriginalFieldName +``` + + In addition, @IsNull_FieldName contains 1 if the source field contains null, and 0 if it does not. This mechanism allows for a performance optimization in SQL Server, and provides for common code that works across multiple providers. + + ]]> + + + + Gets or sets the to use when you load + One of the values. The default is . + + used by the `DataRow.Item` property, or one of the `DataRow.GetChildRows` methods of the object. + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#7](~/sqlclient/doc/samples/SqlParameter.cs#7)] + + ]]> + + + + Gets or sets the of the parameter. + One of the values. The default is . + + and are linked. Therefore, setting the changes the to a supporting . + + For a list of the supported data types, see the appropriate member. For more information, see [DataAdapter Parameters](~/docs/framework/data/adonet/dataadapter-parameters.md). + + For information about streaming, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + + + Gets or sets the value of the parameter as an SQL type. + An that is the value of the parameter, using SQL types. The default value is null. + + that is sent to the server. For output and return value parameters, the value is set on completion of the and after the is closed. + + This property can be set to null or . Use to send a NULL value as the value of the parameter. Use null or do not set to use the default value for the parameter. + + If the application specifies the database type, the bound value is converted to that type when the provider sends the data to the server. The provider tries to convert any type of value if it supports the interface. Conversion errors may result if the specified type is not compatible with the value. + + Both the and properties can be inferred by setting the . + + The property is overwritten by `SqlDataAdapter.UpdateCommand`. + + Use the property to return parameter values as common language runtime (CLR) types. + + For information about streaming, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + ]]> + + + + For a description of this member, see . + A new that is a copy of this instance. + + instance is cast to an interface. + + ]]> + + + + Gets a string that contains the . + A string that contains the . + To be added. + + + Gets or sets the type name for a table-valued parameter. + The type name of the specified table-valued parameter. + To be added. + + + Gets or sets a that represents a user-defined type as a parameter. + A that represents the fully qualified name of a user-defined type in the database. + + , see [Retrieving UDT Data](https://msdn.microsoft.com/library/ms131080.aspx). + + ]]> + + + + Gets or sets the value of the parameter. + An that is the value of the parameter. The default value is null. + + that is sent to the server. For output and return value parameters, the value is set on completion of the and after the is closed. + + This property can be set to `null` or . Use to send a NULL value as the value of the parameter. Use `null` or do not set to use the default value for the parameter. + + An exception is thrown if non-Unicode XML data is passed as a string. + + If the application specifies the database type, the bound value is converted to that type when the provider sends the data to the server. The provider tries to convert any type of value if it supports the interface. Conversion errors may result if the specified type is not compatible with the value. + + Both the and properties can be inferred by setting the Value. + + The property is overwritten by `SqlDataAdapter.UpdateCommand`. + + For information about streaming, see [SqlClient Streaming Support](~/docs/framework/data/adonet/sqlclient-streaming-support.md). + + + +## Examples + The following example creates a and sets some of its properties. + + [!code-csharp[SqlParameter#8](~/sqlclient/doc/samples/SqlParameter.cs#8)] + + ]]> + + + + Gets the name of the database where the schema collection for this XML instance is located. + The name of the database where the schema collection for this XML instance is located. + + and are also null. + + ]]> + + + + Gets the name of the schema collection for this XML instance. + The name of the schema collection for this XML instance. + + and are also null. + + ]]> + + + + The owning relational schema where the schema collection for this XML instance is located. + The owning relational schema for this XML instance. + + and are also null. + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml new file mode 100644 index 0000000000..760a49126c --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml @@ -0,0 +1,366 @@ + + + + + Represents a collection of parameters associated with a and their respective mappings to columns in a . This class cannot be inherited. + + through the collection. The parameters are used to select data within the data source and populate the . This code assumes that a and a have already been created with the appropriate schema, commands, and connection. + + [!code-csharp[SqlParameterCollection_Add6 Example#1](~/sqlclient/doc/samples/SqlParameterCollection_Add6.cs#1)] + + ]]> + + + + Adds a to the . + + + The to add to the collection. + Adds the specified object to the . + A new object. + + + + The specified in the parameter is already added to this or another . + The parameter passed was not a . + The parameter is null. + + + An . + Adds the specified object to the . + The index of the new object. + To be added. + + + The name of the parameter. + One of the values. + Adds a to the given the parameter name and the data type. + A new object. + + + + + + The name of the to add to the collection. + A . + Adds the specified object to the . + A new object. + + Use caution when you are using this overload of the method to specify integer parameter values. Because this overload takes a of type , you must convert the integral value to an type when the value is zero, as the following C# example demonstrates. + +``` +parameters.Add("@pname", Convert.ToInt32(0)); +``` + + If you do not perform this conversion, the compiler assumes that you are trying to call the (, ) overload. + + + + The specified in the parameter is already added to this or another . + The parameter is null. + + + The name of the parameter. + The of the to add to the collection. + The size as an . + Adds a to the , given the specified parameter name, and size. + A new object. + + + + + + The name of the parameter. + One of the values. + The column length. + The name of the source column () if this is used in a call to . + Adds a to the with the parameter name, the data type, and the column length. + A new object. + + + + + + Adds elements to the end of the . + + + The values to add. + Adds an array of values to the end of the . + To be added. + + + The values to add. + Adds an array of values to the end of the . + To be added. + + + The name of the parameter. + The value to be added. Use instead of null, to indicate a null value. + Adds a value to the end of the . + A object. + + replaces the `SqlParameterCollection.Add` method that takes a and an . The overload of `Add` that takes a string and an object was deprecated because of possible ambiguity with the `SqlParameterCollection.Add` overload that takes a and a enumeration value where passing an integer with the string could be interpreted as being either the parameter value or the corresponding value. Use whenever you want to add a parameter by specifying its name and value. + + For `Xml` enumeration values, you can use a string, an XML value, an derived type instance, or a object. + + + +## Examples + The following example demonstrates how to use the `AddWithValue` method. + + [!code-csharp[SqlParameterCollection_AddWithValue#1](~/sqlclient/doc/samples/SqlParameterCollection_AddWithValue.cs#1)] + + ]]> + + + + Removes all the objects from the . + To be added. + + + Determines whether the specified object is in this . + + + The value. + Determines whether the specified is in this . + + if the contains the value; otherwise, . + To be added. + + + The value. + Determines whether the specified is in this . + + if the contains the value; otherwise, . + To be added. + + + The value. + Determines whether the specified parameter name is in this . + + if the contains the value; otherwise, . + To be added. + + + Copies all the elements of the current to the specified object. + + + The one-dimensional that is the destination of the elements copied from the current . + A 32-bit integer that represents the index in the at which copying starts. + Copies all the elements of the current to the specified one-dimensional starting at the specified destination index. + To be added. + + + The that is the destination of the elements copied from the current . + A 32-bit integer that represents the index in the at which copying starts. + Copies all the elements of the current to the specified starting at the specified destination index. + To be added. + + + Returns an Integer that contains the number of elements in the . Read-only. + The number of elements in the as an Integer. + To be added. + + + Returns an enumerator that iterates through the . + An for the . + To be added. + + + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + + + Gets the location of the specified within the collection. + + + The to find. + Gets the location of the specified within the collection. + The zero-based location of the specified that is a within the collection. Returns -1 when the object does not exist in the . + To be added. + + + The to find. + Gets the location of the specified within the collection. + The zero-based location of the specified that is a within the collection. Returns -1 when the object does not exist in the . + To be added. + + + The case-sensitive name of the to find. + Gets the location of the specified with the specified name. + The zero-based location of the specified with the specified case-sensitive name. Returns -1 when the object does not exist in the . + To be added. + + + Inserts a object into the . + + + The zero-based index at which value should be inserted. + A object to be inserted in the . + Inserts a object into the at the specified index. + To be added. + + + The zero-based index at which value should be inserted. + An to be inserted in the . + Inserts an into the at the specified index. + To be added. + + + Gets a value that indicates whether the has a fixed size. + + if the has a fixed size; otherwise, . + To be added. + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + To be added. + + + Gets a value that indicates whether the is synchronized. + + if the is synchronized; otherwise, . + To be added. + + + Gets the with a specified attribute. + + + The zero-based index of the parameter to retrieve. + Gets the at the specified index. + The at the specified index. + + objects to supply an input parameter to a stored procedure that returns results in an output parameter. The code iterates through the items in the and displays some parameter properties in the console window. This example assumes a valid connection string to the **AdventureWorks** sample database on an instance of SQL Server. + + [!code-csharp[SqlParameterCollection_Count Example#1](~/sqlclient/doc/samples/SqlParameterCollection_Count.cs#1)] + + ]]> + + The specified index does not exist. + + + The name of the parameter to retrieve. + Gets the with the specified name. + The with the specified name. + + . If the `parameterName` is not valid, an will be thrown. + + ]]> + + The specified is not valid. + + + Removes the specified from the collection. + + + A object to remove from the collection. + Removes the specified from the collection. + + object in a collection. If the parameter exists, the example removes it. This example assumes that a collection has already been created by a . + + [!code-csharp[SqlParameterCollection_Remove Example#1](~/sqlclient/doc/samples/SqlParameterCollection_Remove.cs#1)] + + ]]> + + The parameter is not a . + The parameter does not exist in the collection. + + + The object to remove from the collection. + Removes the specified from the collection. + To be added. + + + Removes the object from the at the specified index. + + + The zero-based index of the object to remove. + Removes the from the at the specified index. + To be added. + + + The name of the to remove. + Removes the from the at the specified parameter name. + To be added. + + + To be added. + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + To be added. + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml new file mode 100644 index 0000000000..661945ece4 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml @@ -0,0 +1,60 @@ + + + + + Provides data for the event. + + event is raised when an to a row is completed. + + When using , there are two events that occur for each data row updated. The order of execution is as follows: + +1. The values in the are moved to the parameter values. + +2. The event is raised. + +3. The command executes. + +4. If the command is set to `FirstReturnedRecord`, and the first returned result is placed in the . + +5. If there are output parameters, they are placed in the . + +6. The event is raised. + +7. is called. + + + +## Examples + The following example shows how to use both the and events. + + The event returns this output: + + Event Arguments: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0) + + The event returns this output: + + Event Arguments: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0) + + [!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)] + + ]]> + + + + The sent through an . + The executed when is called. + One of the values that specifies the type of query executed. + The sent through an . + Initializes a new instance of the class. + To be added. + + + Gets or sets the executed when is called. + The executed when is called. + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml new file mode 100644 index 0000000000..e0d2fbaa4e --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml @@ -0,0 +1,20 @@ + + + + + The source of the event. + The that contains the event data. + Represents the method that will handle the event of a . + + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](~/docs/standard/events/index.md). + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml new file mode 100644 index 0000000000..cf7cd3120f --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml @@ -0,0 +1,65 @@ + + + + + Provides data for the event. + + event is raised before an to a row. + + When you are using , there are two events that occur for each data row updated. The order of execution is as follows: + +1. The values in the are moved to the parameter values. + +2. The event is raised. + +3. The command executes. + +4. If the command is set to `FirstReturnedRecord`, and the first returned result is placed in the . + +5. If there are output parameters, they are placed in the . + +6. The event is raised. + +7. is called. + + + +## Examples + The following example shows how to use both the and events. + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SQLCommand commandType=2 status=0) + + The event returns this output: + + event args: (command=Microsoft.Data.SqlClient.SQLCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0) + + [!code-csharp[SqlRowUpdatingEventArgs Example#1](~/sqlclient/doc/samples/SqlRowUpdatingEventArgs.cs#1)] + + ]]> + + + + The to . + The to execute during . + One of the values that specifies the type of query executed. + The sent through an . + Initializes a new instance of the class. + To be added. + + + To be added. + To be added. + To be added. + + + Gets or sets the to execute when performing the . + The to execute when performing the . + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml new file mode 100644 index 0000000000..e17361513b --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml @@ -0,0 +1,22 @@ + + + + + The source of the event. + The that contains the event data. + Represents the method that will handle the event of a . + + to influence the processing of the updates. For example, the handler may opt to skip the update of the current row or skip the update of all remaining rows. Note that the rows are updated in the order that they were received from the data source. + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](~/docs/standard/events/index.md). + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml new file mode 100644 index 0000000000..1ae9016785 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml @@ -0,0 +1,51 @@ + + + + + Represents the set of arguments passed to the . + To be added. + + + An that indicates the number of rows copied during the current bulk copy operation. + Creates a new instance of the object. + + + + + + Gets or sets a value that indicates whether the bulk copy operation should be aborted. + + if the bulk copy operation should be aborted; otherwise . + + property to cancel a bulk copy operation. Set to `true` to abort the bulk copy operation. + + If you call the **Close** method from , an exception is generated, and the object state does not change. + + If an application specifically creates a object in the constructor, the transaction is not rolled back. The application is responsible for determining whether it is required to rollback the operation, and if so, it must call the method. If the application does not create a transaction, the internal transaction corresponding to the current batch is automatically rolled back. However, changes related to previous batches within the bulk copy operation are retained, because the transactions for them already have been committed. + + ]]> + + + + Gets a value that returns the number of rows copied during the current bulk copy operation. + + that returns the number of rows copied. + + property is reset on each call to any of the `SqlBulkCopy.WriteToServer` methods. + + ]]> + + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml new file mode 100644 index 0000000000..9033f0032d --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml @@ -0,0 +1,11 @@ + + + + + The source of the event. + A object that contains the event data. + Represents the method that handles the event of a . + To be added. + + + \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml new file mode 100644 index 0000000000..7dec32ea65 --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml @@ -0,0 +1,187 @@ + + + + + Represents a Transact-SQL transaction to be made in a SQL Server database. This class cannot be inherited. + + object by calling on the object. All subsequent operations associated with the transaction (for example, committing or aborting the transaction), are performed on the object. + +> [!NOTE] +> `Try`/`Catch` exception handling should always be used when committing or rolling back a . Both and generate an if the connection is terminated or if the transaction has already been rolled back on the server. + + For more information on SQL Server transactions, see [Explicit Transactions](https://msdn.microsoft.com/library/ms175127\(SQL.105\).aspx) and [Coding Efficient Transactions](https://msdn.microsoft.com/library/ms187484\(SQL.105\).aspx). + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , , and methods. The transaction is rolled back on any error, or if it is disposed without first being committed. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction. + + [!code-csharp[SqlConnection_BeginTransaction Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)] + + ]]> + + + + Commits the database transaction. + + method is equivalent to the Transact-SQL COMMIT TRANSACTION statement. You cannot roll back a transaction once it has been committed, because all modifications have become a permanent part of the database. For more information, see [COMMIT TRANSACTION (Transact-SQL) +](/sql/t-sql/language-elements/commit-transaction-transact-sql). + +> [!NOTE] +> `Try`/`Catch` exception handling should always be used when committing or rolling back a . Both `Commit` and generates an if the connection is terminated or if the transaction has already been rolled back on the server. + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , , and methods. The transaction is rolled back on any error. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction. + + [!code-csharp[SqlConnection_BeginTransaction Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)] + + ]]> + + An error occurred while trying to commit the transaction. + The transaction has already been committed or rolled back. + + -or- + + The connection is broken. + + + Gets the object associated with the transaction, or if the transaction is no longer valid. + The object associated with the transaction. + + . + + ]]> + + + + To be added. + To be added. + To be added. + + + Releases the resources that are held by the object. + To be added. + + + To be added. + To be added. + To be added. + + + Specifies the for this transaction. + The for this transaction. The default is . + + applies to the whole transaction. + + For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels). + + ]]> + + + + Rolls back a transaction from a pending state. + + + Rolls back a transaction from a pending state. + + method is equivalent to the Transact-SQL ROLLBACK TRANSACTION statement. For more information, see [ROLLBACK TRANSACTION (Transact-SQL) +](/sql/t-sql/language-elements/rollback-transaction-transact-sql). + + The transaction can only be rolled back from a pending state (after has been called, but before is called). The transaction is rolled back in the event it is disposed before `Commit` or `Rollback` is called. + +> [!NOTE] +> `Try`/`Catch` exception handling should always be used when rolling back a transaction. A `Rollback` generates an if the connection is terminated or if the transaction has already been rolled back on the server. + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , , and methods. The transaction is rolled back on any error. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction. + + [!code-csharp[SqlConnection_BeginTransaction Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)] + + ]]> + + An error occurred while trying to commit the transaction. + The transaction has already been committed or rolled back. + + -or- + + The connection is broken. + + + The name of the transaction to roll back, or the savepoint to which to roll back. + Rolls back a transaction from a pending state, and specifies the transaction or savepoint name. + + method is equivalent to the Transact-SQL ROLLBACK TRANSACTION statement. For more information, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + + The transaction can only be rolled back from a pending state (after has been called, but before is called). The transaction is rolled back if it is disposed before `Commit` or `Rollback` is called. + +> [!NOTE] +> `Try`/`Catch` exception handling should always be used when rolling back a transaction. A `Rollback` generates an if the connection is terminated or if the transaction has already been rolled back on the server. + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , , and methods. The transaction is rolled back on any error. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction. + + [!code-csharp[SqlConnection_BeginTransaction2 Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction2.cs#1)] + + ]]> + + No transaction name was specified. + The transaction has already been committed or rolled back. + + -or- + + The connection is broken. + + + The name of the savepoint. + Creates a savepoint in the transaction that can be used to roll back a part of the transaction, and specifies the savepoint name. + + method is equivalent to the Transact-SQL SAVE TRANSACTION statement. + + The value used in the `savePoint` parameter can be the same value used in the `transactionName` parameter of some implementations of the method. + + Savepoints offer a mechanism to roll back parts of transactions. You create a savepoint using the method, and then later call the method to roll back to the savepoint instead of rolling back to the start of the transaction. + + ]]> + + An error occurred while trying to commit the transaction. + The transaction has already been committed or rolled back. + + -or- + + The connection is broken. + + + \ No newline at end of file From afeed451ad79a9566db256e0690eaa17011c795c Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 09:16:48 -0700 Subject: [PATCH 03/19] add include tags for SqlConnectionColumnEncryptionSetting.xml and SqlConnectionStringBuilder.xml --- .../SqlConnectionStringBuilder.NetCoreApp.cs | 1 + .../SqlClient/SqlConnectionStringBuilder.cs | 48 +++++++++++++++-- .../src/Microsoft/Data/SqlClient/TdsEnums.cs | 12 ++--- .../SqlClient/SqlConnectionStringBuilder.cs | 53 +++++++++++++++++-- .../src/Microsoft/Data/SqlClient/TdsEnums.cs | 12 ++--- 5 files changed, 100 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs index f3f061552a..a83dd8416f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs @@ -23,6 +23,7 @@ private static PoolBlockingPeriod ConvertToPoolBlockingPeriod(string keyword, ob return DbConnectionStringBuilderUtil.ConvertToPoolBlockingPeriod(keyword, value); } + /// public PoolBlockingPeriod PoolBlockingPeriod { get { return _poolBlockingPeriod; } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs index 1efe8c020b..f5a51befbe 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs @@ -15,6 +15,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed partial class SqlConnectionStringBuilder : DbConnectionStringBuilder { private enum Keywords @@ -217,10 +218,12 @@ private static Dictionary CreateKeywordsDictionary() return hash; } + /// public SqlConnectionStringBuilder() : this((string)null) { } + /// public SqlConnectionStringBuilder(string connectionString) : base() { if (!string.IsNullOrEmpty(connectionString)) @@ -229,6 +232,7 @@ public SqlConnectionStringBuilder(string connectionString) : base() } } + /// public override object this[string keyword] { get @@ -358,6 +362,7 @@ public override object this[string keyword] } } + /// public ApplicationIntent ApplicationIntent { get { return _applicationIntent; } @@ -373,6 +378,7 @@ public ApplicationIntent ApplicationIntent } } + /// public string ApplicationName { get { return _applicationName; } @@ -383,6 +389,7 @@ public string ApplicationName } } + /// public string AttachDBFilename { get { return _attachDBFilename; } @@ -393,6 +400,7 @@ public string AttachDBFilename } } + /// public int ConnectTimeout { get { return _connectTimeout; } @@ -407,6 +415,7 @@ public int ConnectTimeout } } + /// public string CurrentLanguage { get { return _currentLanguage; } @@ -417,6 +426,7 @@ public string CurrentLanguage } } + /// public string DataSource { get { return _dataSource; } @@ -427,6 +437,7 @@ public string DataSource } } + /// public bool Encrypt { get { return _encrypt; } @@ -437,7 +448,7 @@ public bool Encrypt } } - + /// public SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting { get { return _columnEncryptionSetting; } @@ -453,7 +464,7 @@ public SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting } } - + /// public string EnclaveAttestationUrl { get { return _enclaveAttestationUrl; } @@ -464,6 +475,7 @@ public string EnclaveAttestationUrl } } + /// public bool TrustServerCertificate { get { return _trustServerCertificate; } @@ -474,6 +486,7 @@ public bool TrustServerCertificate } } + /// public bool Enlist { get { return _enlist; } @@ -484,6 +497,7 @@ public bool Enlist } } + /// public string FailoverPartner { get { return _failoverPartner; } @@ -494,6 +508,7 @@ public string FailoverPartner } } + /// [TypeConverter(typeof(SqlInitialCatalogConverter))] public string InitialCatalog { @@ -505,6 +520,7 @@ public string InitialCatalog } } + /// public bool IntegratedSecurity { get { return _integratedSecurity; } @@ -515,6 +531,7 @@ public bool IntegratedSecurity } } + /// public SqlAuthenticationMethod Authentication { get { return _authentication; } @@ -530,6 +547,7 @@ public SqlAuthenticationMethod Authentication } } + /// public int LoadBalanceTimeout { get { return _loadBalanceTimeout; } @@ -544,6 +562,7 @@ public int LoadBalanceTimeout } } + /// public int MaxPoolSize { get { return _maxPoolSize; } @@ -558,6 +577,7 @@ public int MaxPoolSize } } + /// public int ConnectRetryCount { get { return _connectRetryCount; } @@ -572,6 +592,7 @@ public int ConnectRetryCount } } + /// public int ConnectRetryInterval { get { return _connectRetryInterval; } @@ -587,7 +608,7 @@ public int ConnectRetryInterval } - + /// public int MinPoolSize { get { return _minPoolSize; } @@ -602,6 +623,7 @@ public int MinPoolSize } } + /// public bool MultipleActiveResultSets { get { return _multipleActiveResultSets; } @@ -612,6 +634,7 @@ public bool MultipleActiveResultSets } } + /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Reviewed and Approved by UE")] public bool MultiSubnetFailover { @@ -636,6 +659,7 @@ public string NamedConnection { } } */ + /// public int PacketSize { get { return _packetSize; } @@ -650,6 +674,7 @@ public int PacketSize } } + /// public string Password { get { return _password; } @@ -660,6 +685,7 @@ public string Password } } + /// public bool PersistSecurityInfo { get { return _persistSecurityInfo; } @@ -670,6 +696,7 @@ public bool PersistSecurityInfo } } + /// public bool Pooling { get { return _pooling; } @@ -680,6 +707,7 @@ public bool Pooling } } + /// public bool Replication { get { return _replication; } @@ -690,6 +718,7 @@ public bool Replication } } + /// public string TransactionBinding { get { return _transactionBinding; } @@ -700,6 +729,7 @@ public string TransactionBinding } } + /// public string TypeSystemVersion { get { return _typeSystemVersion; } @@ -710,6 +740,7 @@ public string TypeSystemVersion } } + /// public string UserID { get { return _userID; } @@ -720,6 +751,7 @@ public string UserID } } + /// public bool UserInstance { get { return _userInstance; } @@ -730,6 +762,7 @@ public bool UserInstance } } + /// public string WorkstationID { get { return _workstationID; } @@ -740,7 +773,7 @@ public string WorkstationID } } - + /// public override ICollection Keys { get @@ -749,6 +782,7 @@ public override ICollection Keys } } + /// public override ICollection Values { get @@ -764,6 +798,7 @@ public override ICollection Values } } + /// public override void Clear() { base.Clear(); @@ -773,6 +808,7 @@ public override void Clear() } } + /// public override bool ContainsKey(string keyword) { ADP.CheckArgumentNull(keyword, nameof(keyword)); @@ -904,7 +940,7 @@ private Keywords GetIndex(string keyword) throw UnsupportedKeyword(keyword); } - + /// public override bool Remove(string keyword) { ADP.CheckArgumentNull(keyword, nameof(keyword)); @@ -1064,6 +1100,7 @@ private void SetAuthenticationValue(SqlAuthenticationMethod value) base[DbConnectionStringKeywords.Authentication] = DbConnectionStringBuilderUtil.AuthenticationTypeToString(value); } + /// public override bool ShouldSerialize(string keyword) { ADP.CheckArgumentNull(keyword, nameof(keyword)); @@ -1071,6 +1108,7 @@ public override bool ShouldSerialize(string keyword) return s_keywords.TryGetValue(keyword, out index) && base.ShouldSerialize(s_validKeywords[(int)index]); } + /// public override bool TryGetValue(string keyword, out object value) { Keywords index; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs index e084ac5a5b..7b90a1e1e7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs @@ -1045,19 +1045,13 @@ internal enum ParsingErrorState DataClassificationInvalidInformationTypeIndex = 27 } - /// - /// Column Encryption Setting to be used for the SqlConnection. - /// + /// public enum SqlConnectionColumnEncryptionSetting { - /// - /// Disables column encryption by default on all commands on this connection. - /// + /// Disabled = 0, - /// - /// Enables column encryption by default on all commands on this connection. - /// + /// Enabled, } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs index d38f9b851a..6d31b3064e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs @@ -16,7 +16,7 @@ namespace Microsoft.Data.SqlClient { - + /// [DefaultProperty("DataSource")] [System.ComponentModel.TypeConverterAttribute(typeof(SqlConnectionStringBuilder.SqlConnectionStringBuilderConverter))] public sealed class SqlConnectionStringBuilder : DbConnectionStringBuilder @@ -254,10 +254,12 @@ static SqlConnectionStringBuilder() } + /// public SqlConnectionStringBuilder() : this((string)null) { } + /// public SqlConnectionStringBuilder(string connectionString) : base() { if (!ADP.IsEmpty(connectionString)) @@ -266,6 +268,7 @@ public SqlConnectionStringBuilder(string connectionString) : base() } } + /// public override object this[string keyword] { get @@ -416,6 +419,7 @@ public override object this[string keyword] } } + /// [DisplayName(DbConnectionStringKeywords.ApplicationIntent)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Initialization)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ApplicationIntent)] @@ -435,6 +439,7 @@ public ApplicationIntent ApplicationIntent } } + /// [DisplayName(DbConnectionStringKeywords.ApplicationName)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Context)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ApplicationName)] @@ -449,6 +454,7 @@ public string ApplicationName } } + /// [DisplayName(DbConnectionStringKeywords.AsynchronousProcessing)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Initialization)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_AsynchronousProcessing)] @@ -463,6 +469,7 @@ public bool AsynchronousProcessing } } + /// [DisplayName(DbConnectionStringKeywords.AttachDBFilename)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_AttachDBFilename)] @@ -479,6 +486,7 @@ public string AttachDBFilename } } + /// [DisplayName(DbConnectionStringKeywords.PoolBlockingPeriod)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_PoolBlockingPeriod)] @@ -498,6 +506,7 @@ public PoolBlockingPeriod PoolBlockingPeriod } } + /// [Browsable(false)] [DisplayName(DbConnectionStringKeywords.ConnectionReset)] [Obsolete("ConnectionReset has been deprecated. SqlConnection will ignore the 'connection reset' keyword and always reset the connection")] // SQLPT 41700 @@ -514,6 +523,7 @@ public bool ConnectionReset } } + /// [DisplayName(DbConnectionStringKeywords.ContextConnection)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ContextConnection)] @@ -528,6 +538,7 @@ public bool ContextConnection } } + /// [DisplayName(DbConnectionStringKeywords.ConnectTimeout)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Initialization)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ConnectTimeout)] @@ -546,6 +557,7 @@ public int ConnectTimeout } } + /// [DisplayName(DbConnectionStringKeywords.CurrentLanguage)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Initialization)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_CurrentLanguage)] @@ -560,6 +572,7 @@ public string CurrentLanguage } } + /// [DisplayName(DbConnectionStringKeywords.DataSource)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_DataSource)] @@ -575,6 +588,7 @@ public string DataSource } } + /// [DisplayName(DbConnectionStringKeywords.Encrypt)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_Encrypt)] @@ -589,6 +603,7 @@ public bool Encrypt } } + /// [DisplayName(DbConnectionStringKeywords.ColumnEncryptionSetting)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.TCE_DbConnectionString_ColumnEncryptionSetting)] @@ -608,6 +623,7 @@ public SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting } } + /// [DisplayName(DbConnectionStringKeywords.EnclaveAttestationUrl)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.TCE_DbConnectionString_EnclaveAttestationUrl)] @@ -622,6 +638,7 @@ public string EnclaveAttestationUrl } } + /// [DisplayName(DbConnectionStringKeywords.TrustServerCertificate)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_TrustServerCertificate)] @@ -636,6 +653,7 @@ public bool TrustServerCertificate } } + /// [DisplayName(DbConnectionStringKeywords.Enlist)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_Enlist)] @@ -650,6 +668,7 @@ public bool Enlist } } + /// [DisplayName(DbConnectionStringKeywords.FailoverPartner)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_FailoverPartner)] @@ -665,6 +684,7 @@ public string FailoverPartner } } + /// [DisplayName(DbConnectionStringKeywords.InitialCatalog)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_InitialCatalog)] @@ -680,6 +700,7 @@ public string InitialCatalog } } + /// [DisplayName(DbConnectionStringKeywords.IntegratedSecurity)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_IntegratedSecurity)] @@ -694,6 +715,7 @@ public bool IntegratedSecurity } } + /// [DisplayName(DbConnectionStringKeywords.Authentication)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_Authentication)] @@ -736,7 +758,7 @@ internal string Certificate } #endif - + /// [DisplayName(DbConnectionStringKeywords.LoadBalanceTimeout)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_LoadBalanceTimeout)] @@ -755,6 +777,7 @@ public int LoadBalanceTimeout } } + /// [DisplayName(DbConnectionStringKeywords.MaxPoolSize)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_MaxPoolSize)] @@ -773,6 +796,7 @@ public int MaxPoolSize } } + /// [DisplayName(DbConnectionStringKeywords.ConnectRetryCount)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_ConnectionResilency)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ConnectRetryCount)] @@ -791,6 +815,7 @@ public int ConnectRetryCount } } + /// [DisplayName(DbConnectionStringKeywords.ConnectRetryInterval)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_ConnectionResilency)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_ConnectRetryInterval)] @@ -810,7 +835,7 @@ public int ConnectRetryInterval } - + /// [DisplayName(DbConnectionStringKeywords.MinPoolSize)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_MinPoolSize)] @@ -829,6 +854,7 @@ public int MinPoolSize } } + /// [DisplayName(DbConnectionStringKeywords.MultipleActiveResultSets)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Advanced)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_MultipleActiveResultSets)] @@ -843,6 +869,7 @@ public bool MultipleActiveResultSets } } + /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Reviewed and Approved by UE")] [DisplayName(DbConnectionStringKeywords.MultiSubnetFailover)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] @@ -858,6 +885,7 @@ public bool MultiSubnetFailover } } + /// [DisplayName(DbConnectionStringKeywords.TransparentNetworkIPResolution)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_TransparentNetworkIPResolution)] @@ -885,6 +913,7 @@ public string NamedConnection { } } */ + /// [DisplayName(DbConnectionStringKeywords.NetworkLibrary)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Advanced)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_NetworkLibrary)] @@ -932,6 +961,7 @@ public string NetworkLibrary } } + /// [DisplayName(DbConnectionStringKeywords.PacketSize)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Advanced)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_PacketSize)] @@ -950,6 +980,7 @@ public int PacketSize } } + /// [DisplayName(DbConnectionStringKeywords.Password)] [PasswordPropertyTextAttribute(true)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] @@ -965,6 +996,7 @@ public string Password } } + /// [DisplayName(DbConnectionStringKeywords.PersistSecurityInfo)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_PersistSecurityInfo)] @@ -979,6 +1011,7 @@ public bool PersistSecurityInfo } } + /// [DisplayName(DbConnectionStringKeywords.Pooling)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Pooling)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_Pooling)] @@ -993,6 +1026,7 @@ public bool Pooling } } + /// [DisplayName(DbConnectionStringKeywords.Replication)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Replication)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_Replication)] @@ -1007,6 +1041,7 @@ public bool Replication } } + /// [DisplayName(DbConnectionStringKeywords.TransactionBinding)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Advanced)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_TransactionBinding)] @@ -1021,6 +1056,7 @@ public string TransactionBinding } } + /// [DisplayName(DbConnectionStringKeywords.TypeSystemVersion)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Advanced)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_TypeSystemVersion)] @@ -1035,6 +1071,7 @@ public string TypeSystemVersion } } + /// [DisplayName(DbConnectionStringKeywords.UserID)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Security)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_UserID)] @@ -1049,6 +1086,7 @@ public string UserID } } + /// [DisplayName(DbConnectionStringKeywords.UserInstance)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Source)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_UserInstance)] @@ -1063,6 +1101,7 @@ public bool UserInstance } } + /// [DisplayName(DbConnectionStringKeywords.WorkstationID)] [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Context)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnectionString_WorkstationID)] @@ -1077,6 +1116,7 @@ public string WorkstationID } } + /// public override bool IsFixedSize { get @@ -1085,6 +1125,7 @@ public override bool IsFixedSize } } + /// public override ICollection Keys { get @@ -1093,6 +1134,7 @@ public override ICollection Keys } } + /// public override ICollection Values { get @@ -1108,6 +1150,7 @@ public override ICollection Values } } + /// public override void Clear() { base.Clear(); @@ -1117,6 +1160,7 @@ public override void Clear() } } + /// public override bool ContainsKey(string keyword) { ADP.CheckArgumentNull(keyword, "keyword"); @@ -1292,6 +1336,7 @@ protected override void GetProperties(Hashtable propertyDescriptors) { base.GetProperties(propertyDescriptors); } */ + /// public override bool Remove(string keyword) { ADP.CheckArgumentNull(keyword, "keyword"); @@ -1473,6 +1518,7 @@ private void SetColumnEncryptionSettingValue(SqlConnectionColumnEncryptionSettin base[DbConnectionStringKeywords.ColumnEncryptionSetting] = DbConnectionStringBuilderUtil.ColumnEncryptionSettingToString(value); } + /// public override bool ShouldSerialize(string keyword) { ADP.CheckArgumentNull(keyword, "keyword"); @@ -1480,6 +1526,7 @@ public override bool ShouldSerialize(string keyword) return _keywords.TryGetValue(keyword, out index) && base.ShouldSerialize(_validKeywords[(int)index]); } + /// public override bool TryGetValue(string keyword, out object value) { Keywords index; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs index 7914784d72..74ebb081ac 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs @@ -1009,19 +1009,13 @@ internal enum SniContext Snix_SendRows, } - /// - /// Column Encryption Setting to be used for the SqlConnection. - /// + /// public enum SqlConnectionColumnEncryptionSetting { - /// - /// Disables column encryption by default on all commands on this connection. - /// + /// Disabled = 0, - /// - /// Enables column encryption by default on all commands on this connection. - /// + /// Enabled, } From 869a0aa05a1955c3c7480e49f9ce074221d72f93 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 09:47:21 -0700 Subject: [PATCH 04/19] add include tags for SqlCredential.xml --- .../Microsoft.Data.SqlClient/SqlCredential.xml | 1 - .../src/Microsoft/Data/SqlClient/SqlCredential.cs | 4 ++++ .../src/Microsoft/Data/SqlClient/SqlCredential.cs | 10 ++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml index 2b65e81146..c2389f407a 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml @@ -59,7 +59,6 @@ conn.Open(); The user id. - To be added. The password; a value marked as read-only. Passing a read/write parameter will raise an . Creates an object of type . diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCredential.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCredential.cs index 72ea549cde..89ff691a20 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCredential.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCredential.cs @@ -7,11 +7,13 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlCredential { string _userId; SecureString _password; + /// public SqlCredential(string userId, SecureString password) { if (userId == null) @@ -43,8 +45,10 @@ public SqlCredential(string userId, SecureString password) _password = password; } + /// public string UserId => _userId; + /// public SecureString Password => _password; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCredential.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCredential.cs index e3a5d16591..52c2fb36fd 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCredential.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCredential.cs @@ -7,6 +7,7 @@ namespace Microsoft.Data.SqlClient { + /// // Represent a pair of user id and password which to be used for SQL Authentication // SqlCredential takes password as SecureString which is better way to store security sensitive information // This class is immutable @@ -15,14 +16,11 @@ public sealed class SqlCredential string _userId; SecureString _password; - // + /// // PUBLIC CONSTRUCTOR - // - // SqlCredential // userId: userId // password: password - // public SqlCredential(string userId, SecureString password) { if (userId == null) @@ -54,9 +52,8 @@ public SqlCredential(string userId, SecureString password) _password = password; } - // + /// // PUBLIC PROPERTIES - // public string UserId { get @@ -65,6 +62,7 @@ public string UserId } } + /// public SecureString Password { get From 366fb1812969064934e0071f82cae2a51bce6aa6 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 10:17:17 -0700 Subject: [PATCH 05/19] add include tags for SqlDataAdapter.xml --- .../Data/SqlClient/SqlDataAdapter.cs | 28 ++++++++++++++++++ .../Data/SqlClient/SqlDataAdapter.cs | 29 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index b0bc40a54c..c33cd99361 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -10,6 +10,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable { private static readonly object EventRowUpdated = new object(); @@ -20,22 +21,26 @@ public sealed class SqlDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable private SqlCommandSet _commandSet; private int _updateBatchSize = 1; + /// public SqlDataAdapter() : base() { GC.SuppressFinalize(this); } + /// public SqlDataAdapter(SqlCommand selectCommand) : this() { SelectCommand = selectCommand; } + /// public SqlDataAdapter(string selectCommandText, string selectConnectionString) : this() { SqlConnection connection = new SqlConnection(selectConnectionString); SelectCommand = new SqlCommand(selectCommandText, connection); } + /// public SqlDataAdapter(string selectCommandText, SqlConnection selectConnection) : this() { SelectCommand = new SqlCommand(selectCommandText, selectConnection); @@ -46,54 +51,63 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) GC.SuppressFinalize(this); } + /// new public SqlCommand DeleteCommand { get { return _deleteCommand; } set { _deleteCommand = value; } } + /// IDbCommand IDbDataAdapter.DeleteCommand { get { return _deleteCommand; } set { _deleteCommand = (SqlCommand)value; } } + /// new public SqlCommand InsertCommand { get { return _insertCommand; } set { _insertCommand = value; } } + /// IDbCommand IDbDataAdapter.InsertCommand { get { return _insertCommand; } set { _insertCommand = (SqlCommand)value; } } + /// new public SqlCommand SelectCommand { get { return _selectCommand; } set { _selectCommand = value; } } + /// IDbCommand IDbDataAdapter.SelectCommand { get { return _selectCommand; } set { _selectCommand = (SqlCommand)value; } } + /// new public SqlCommand UpdateCommand { get { return _updateCommand; } set { _updateCommand = value; } } + /// IDbCommand IDbDataAdapter.UpdateCommand { get { return _updateCommand; } set { _updateCommand = (SqlCommand)value; } } + /// public override int UpdateBatchSize { get @@ -110,6 +124,7 @@ public override int UpdateBatchSize } } + /// protected override int AddToBatch(IDbCommand command) { int commandIdentifier = _commandSet.CommandCount; @@ -117,17 +132,20 @@ protected override int AddToBatch(IDbCommand command) return commandIdentifier; } + /// protected override void ClearBatch() { _commandSet.Clear(); } + /// protected override int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); return _commandSet.ExecuteNonQuery(); } + /// protected override IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); @@ -136,12 +154,14 @@ protected override IDataParameter GetBatchedParameter(int commandIdentifier, int return parameter; } + /// protected override bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception error) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); return _commandSet.GetBatchedAffected(commandIdentifier, out recordsAffected, out error); } + /// protected override void InitializeBatching() { _commandSet = new SqlCommandSet(); @@ -166,6 +186,7 @@ protected override void InitializeBatching() } } + /// protected override void TerminateBatching() { if (null != _commandSet) @@ -175,21 +196,25 @@ protected override void TerminateBatching() } } + /// object ICloneable.Clone() { return new SqlDataAdapter(this); } + /// protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping); } + /// protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); } + /// public event SqlRowUpdatedEventHandler RowUpdated { add @@ -202,6 +227,7 @@ public event SqlRowUpdatedEventHandler RowUpdated } } + /// public event SqlRowUpdatingEventHandler RowUpdating { add @@ -226,6 +252,7 @@ public event SqlRowUpdatingEventHandler RowUpdating } } + /// override protected void OnRowUpdated(RowUpdatedEventArgs value) { SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[EventRowUpdated]; @@ -236,6 +263,7 @@ override protected void OnRowUpdated(RowUpdatedEventArgs value) base.OnRowUpdated(value); } + /// override protected void OnRowUpdating(RowUpdatingEventArgs value) { SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index 884b9ab7c0..b8f33b6d94 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -11,6 +11,7 @@ namespace Microsoft.Data.SqlClient { + /// [ DefaultEvent("RowUpdated"), ToolboxItem("Microsoft.VSDesigner.Data.VS.SqlDataAdapterToolboxItem, " + AssemblyRef.MicrosoftVSDesigner), @@ -37,22 +38,26 @@ internal int ObjectID return _objectID; } } + /// public SqlDataAdapter() : base() { GC.SuppressFinalize(this); } + /// public SqlDataAdapter(SqlCommand selectCommand) : this() { SelectCommand = selectCommand; } + /// public SqlDataAdapter(string selectCommandText, string selectConnectionString) : this() { SqlConnection connection = new SqlConnection(selectConnectionString); SelectCommand = new SqlCommand(selectCommandText, connection); } + /// public SqlDataAdapter(string selectCommandText, SqlConnection selectConnection) : this() { SelectCommand = new SqlCommand(selectCommandText, selectConnection); @@ -63,6 +68,7 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) GC.SuppressFinalize(this); } + /// [ DefaultValue(null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), @@ -75,12 +81,14 @@ private SqlDataAdapter(SqlDataAdapter from) : base(from) set { _deleteCommand = value; } } + /// IDbCommand IDbDataAdapter.DeleteCommand { get { return _deleteCommand; } set { _deleteCommand = (SqlCommand)value; } } + /// [ DefaultValue(null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), @@ -93,12 +101,14 @@ IDbCommand IDbDataAdapter.DeleteCommand set { _insertCommand = value; } } + /// IDbCommand IDbDataAdapter.InsertCommand { get { return _insertCommand; } set { _insertCommand = (SqlCommand)value; } } + /// [ DefaultValue(null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), @@ -111,13 +121,14 @@ IDbCommand IDbDataAdapter.InsertCommand set { _selectCommand = value; } } + /// IDbCommand IDbDataAdapter.SelectCommand { get { return _selectCommand; } set { _selectCommand = (SqlCommand)value; } } - + /// override public int UpdateBatchSize { get @@ -135,6 +146,7 @@ override public int UpdateBatchSize } } + /// [ DefaultValue(null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), @@ -147,12 +159,14 @@ override public int UpdateBatchSize set { _updateCommand = value; } } + /// IDbCommand IDbDataAdapter.UpdateCommand { get { return _updateCommand; } set { _updateCommand = (SqlCommand)value; } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdated), @@ -169,6 +183,7 @@ public event SqlRowUpdatedEventHandler RowUpdated } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataAdapter_RowUpdating), @@ -198,6 +213,7 @@ public event SqlRowUpdatingEventHandler RowUpdating } } + /// override protected int AddToBatch(IDbCommand command) { int commandIdentifier = _commandSet.CommandCount; @@ -205,26 +221,31 @@ override protected int AddToBatch(IDbCommand command) return commandIdentifier; } + /// override protected void ClearBatch() { _commandSet.Clear(); } + /// object ICloneable.Clone() { return new SqlDataAdapter(this); } + /// override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping); } + /// override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { return new SqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); } + /// override protected int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); @@ -232,6 +253,7 @@ override protected int ExecuteBatch() return _commandSet.ExecuteNonQuery(); } + /// override protected IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); @@ -240,12 +262,14 @@ override protected IDataParameter GetBatchedParameter(int commandIdentifier, int return parameter; } + /// override protected bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception error) { Debug.Assert(commandIdentifier < _commandSet.CommandCount, "commandIdentifier out of range"); return _commandSet.GetBatchedAffected(commandIdentifier, out recordsAffected, out error); } + /// override protected void InitializeBatching() { Bid.Trace(" %d#\n", ObjectID); @@ -271,6 +295,7 @@ override protected void InitializeBatching() } } + /// override protected void OnRowUpdated(RowUpdatedEventArgs value) { SqlRowUpdatedEventHandler handler = (SqlRowUpdatedEventHandler)Events[EventRowUpdated]; @@ -281,6 +306,7 @@ override protected void OnRowUpdated(RowUpdatedEventArgs value) base.OnRowUpdated(value); } + /// override protected void OnRowUpdating(RowUpdatingEventArgs value) { SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler)Events[EventRowUpdating]; @@ -291,6 +317,7 @@ override protected void OnRowUpdating(RowUpdatingEventArgs value) base.OnRowUpdating(value); } + /// override protected void TerminateBatching() { if (null != _commandSet) From bbcb07389748823858151baac5a0d1a3a9f69b91 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 14:47:37 -0700 Subject: [PATCH 06/19] add includes for SqlDataReader.xml --- .../SqlDataReader.xml | 8 +-- .../Microsoft/Data/SqlClient/SqlDataReader.cs | 71 ++++++++++++++++++- .../Microsoft/Data/SqlClient/SqlDataReader.cs | 70 +++++++++++++++++- 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml index 0e59c70bc2..344880d6a6 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml @@ -324,7 +324,7 @@ Trying to read a column that does not exist. The value of the column was null ( == ), retrieving a non-SQL type. - doesn't match the type returned by SQL Server or cannot be cast. + doesn't match the type returned by SQL Server or cannot be cast. The type of the value to be returned. @@ -366,7 +366,7 @@ Trying to read a column that does not exist. The value of the column was null ( == ), retrieving a non-SQL type. - doesn't match the type returned by SQL Server or cannot be cast. + doesn't match the type returned by SQL Server or cannot be cast. The zero-based column ordinal. @@ -1193,8 +1193,8 @@ - Releases all resources that are used by the data reader. - To be added. + Releases all resources that are used by the data reader. + To be added. Gets the number of fields in the that are not hidden. diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs index 6b861e6676..e1613251b0 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -24,6 +24,7 @@ namespace Microsoft.Data.SqlClient { + /// public class SqlDataReader : DbDataReader, IDataReader, IDbColumnSchemaGenerator { private enum ALTROWSTATUS @@ -137,6 +138,7 @@ internal SqlCommand Command } } + /// protected SqlConnection Connection { get @@ -147,6 +149,7 @@ protected SqlConnection Connection public SensitivityClassification SensitivityClassification { get; internal set; } + /// override public int Depth { get @@ -160,6 +163,7 @@ override public int Depth } } + /// // fields/attributes collection override public int FieldCount { @@ -183,6 +187,7 @@ override public int FieldCount } } + /// override public bool HasRows { get @@ -200,6 +205,7 @@ override public bool HasRows } } + /// override public bool IsClosed { get @@ -343,6 +349,7 @@ internal virtual SmiExtendedMetaData[] GetInternalSmiMetaData() return metaDataReturn; } + /// override public int RecordsAffected { get @@ -383,6 +390,7 @@ internal MultiPartTableName[] TableNames } } + /// override public int VisibleFieldCount { get @@ -400,6 +408,7 @@ override public int VisibleFieldCount } } + /// // this operator override public object this[int i] { @@ -409,6 +418,7 @@ override public object this[int i] } } + /// override public object this[string name] { get @@ -817,6 +827,7 @@ private void CleanPartialReadReliable() Debug.Assert(!_sharedState._dataReady, "_dataReady should be cleared"); } + /// protected override void Dispose(bool disposing) { if (disposing) @@ -826,6 +837,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + /// public override void Close() { SqlStatistics statistics = null; @@ -1153,6 +1165,7 @@ private bool TryConsumeMetaData() return true; } + /// override public string GetDataTypeName(int i) { SqlStatistics statistics = null; @@ -1228,11 +1241,13 @@ virtual internal SqlBuffer.StorageType GetVariantInternalStorageType(int i) return _data[i].VariantInternalStorageType; } + /// override public IEnumerator GetEnumerator() { return new DbEnumerator(this, IsCommandBehavior(CommandBehavior.CloseConnection)); } + /// override public Type GetFieldType(int i) { SqlStatistics statistics = null; @@ -1333,12 +1348,14 @@ virtual internal int GetLocaleId(int i) return lcid; } + /// override public string GetName(int i) { CheckMetaDataIsReady(columnIndex: i); return _metaData[i].column; } + /// override public Type GetProviderSpecificFieldType(int i) { SqlStatistics statistics = null; @@ -1407,6 +1424,7 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData) return providerSpecificFieldType; } + /// // named field access override public int GetOrdinal(string name) { @@ -1427,16 +1445,19 @@ override public int GetOrdinal(string name) } } + /// override public object GetProviderSpecificValue(int i) { return GetSqlValue(i); } + /// override public int GetProviderSpecificValues(object[] values) { return GetSqlValues(values); } + /// public override DataTable GetSchemaTable() { SqlStatistics statistics = null; @@ -1459,12 +1480,14 @@ public override DataTable GetSchemaTable() } } + /// override public bool GetBoolean(int i) { ReadColumn(i); return _data[i].Boolean; } + /// virtual public XmlReader GetXmlReader(int i) { // NOTE: sql_variant can not contain a XML data type: http://msdn.microsoft.com/en-us/library/ms173829.aspx @@ -1504,6 +1527,7 @@ virtual public XmlReader GetXmlReader(int i) } } + /// override public Stream GetStream(int i) { CheckDataIsReady(columnIndex: i); @@ -1551,12 +1575,14 @@ override public Stream GetStream(int i) } } + /// override public byte GetByte(int i) { ReadColumn(i); return _data[i].Byte; } + /// override public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length) { SqlStatistics statistics = null; @@ -1900,6 +1926,7 @@ internal bool TryGetBytesInternalSequential(int i, byte[] buffer, int index, int } } + /// override public TextReader GetTextReader(int i) { CheckDataIsReady(columnIndex: i); @@ -1969,11 +1996,13 @@ override public TextReader GetTextReader(int i) } } + /// override public char GetChar(int i) { throw ADP.NotSupported(); } + /// override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length) { SqlStatistics statistics = null; @@ -2261,7 +2290,7 @@ internal long GetStreamingXmlChars(int i, long dataIndex, char[] buffer, int buf return cnt; } - + /// override public DateTime GetDateTime(int i) { ReadColumn(i); @@ -2283,66 +2312,77 @@ override public DateTime GetDateTime(int i) return dt; } + /// override public decimal GetDecimal(int i) { ReadColumn(i); return _data[i].Decimal; } + /// override public double GetDouble(int i) { ReadColumn(i); return _data[i].Double; } + /// override public float GetFloat(int i) { ReadColumn(i); return _data[i].Single; } + /// override public Guid GetGuid(int i) { ReadColumn(i); return _data[i].Guid; } + /// override public short GetInt16(int i) { ReadColumn(i); return _data[i].Int16; } + /// override public int GetInt32(int i) { ReadColumn(i); return _data[i].Int32; } + /// override public long GetInt64(int i) { ReadColumn(i); return _data[i].Int64; } + /// virtual public SqlBoolean GetSqlBoolean(int i) { ReadColumn(i); return _data[i].SqlBoolean; } + /// virtual public SqlBinary GetSqlBinary(int i) { ReadColumn(i, setTimeout: true, allowPartiallyReadColumn: true); return _data[i].SqlBinary; } + /// virtual public SqlByte GetSqlByte(int i) { ReadColumn(i); return _data[i].SqlByte; } + /// virtual public SqlBytes GetSqlBytes(int i) { ReadColumn(i); @@ -2350,6 +2390,7 @@ virtual public SqlBytes GetSqlBytes(int i) return new SqlBytes(data); } + /// virtual public SqlChars GetSqlChars(int i) { ReadColumn(i); @@ -2366,60 +2407,70 @@ virtual public SqlChars GetSqlChars(int i) return new SqlChars(data); } + /// virtual public SqlDateTime GetSqlDateTime(int i) { ReadColumn(i); return _data[i].SqlDateTime; } + /// virtual public SqlDecimal GetSqlDecimal(int i) { ReadColumn(i); return _data[i].SqlDecimal; } + /// virtual public SqlGuid GetSqlGuid(int i) { ReadColumn(i); return _data[i].SqlGuid; } + /// virtual public SqlDouble GetSqlDouble(int i) { ReadColumn(i); return _data[i].SqlDouble; } + /// virtual public SqlInt16 GetSqlInt16(int i) { ReadColumn(i); return _data[i].SqlInt16; } + /// virtual public SqlInt32 GetSqlInt32(int i) { ReadColumn(i); return _data[i].SqlInt32; } + /// virtual public SqlInt64 GetSqlInt64(int i) { ReadColumn(i); return _data[i].SqlInt64; } + /// virtual public SqlMoney GetSqlMoney(int i) { ReadColumn(i); return _data[i].SqlMoney; } + /// virtual public SqlSingle GetSqlSingle(int i) { ReadColumn(i); return _data[i].SqlSingle; } + /// virtual public SqlString GetSqlString(int i) { ReadColumn(i); @@ -2432,6 +2483,7 @@ virtual public SqlString GetSqlString(int i) return _data[i].SqlString; } + /// virtual public SqlXml GetSqlXml(int i) { ReadColumn(i); @@ -2462,6 +2514,7 @@ virtual public SqlXml GetSqlXml(int i) return sx; } + /// virtual public object GetSqlValue(int i) { SqlStatistics statistics = null; @@ -2547,6 +2600,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met } } + /// virtual public int GetSqlValues(object[] values) { SqlStatistics statistics = null; @@ -2575,6 +2629,7 @@ virtual public int GetSqlValues(object[] values) } } + /// override public string GetString(int i) { ReadColumn(i); @@ -2588,6 +2643,7 @@ override public string GetString(int i) return _data[i].String; } + /// override public T GetFieldValue(int i) { SqlStatistics statistics = null; @@ -2604,6 +2660,7 @@ override public T GetFieldValue(int i) } } + /// override public object GetValue(int i) { SqlStatistics statistics = null; @@ -2620,6 +2677,7 @@ override public object GetValue(int i) } } + /// virtual public TimeSpan GetTimeSpan(int i) { ReadColumn(i); @@ -2641,6 +2699,7 @@ virtual public TimeSpan GetTimeSpan(int i) return t; } + /// virtual public DateTimeOffset GetDateTimeOffset(int i) { ReadColumn(i); @@ -2882,6 +2941,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met } } + /// override public int GetValues(object[] values) { SqlStatistics statistics = null; @@ -3148,6 +3208,7 @@ private bool IsRowToken(byte token) return TdsEnums.SQLROW == token || TdsEnums.SQLNBCROW == token; } + /// override public bool IsDBNull(int i) { { @@ -3161,11 +3222,13 @@ override public bool IsDBNull(int i) return _data[i].IsNull; } + /// protected internal bool IsCommandBehavior(CommandBehavior condition) { return (condition == (condition & _commandBehavior)); } + /// override public bool NextResult() { if (_currentTask != null) @@ -3323,6 +3386,7 @@ private bool TryNextResult(out bool more) } } + /// // user must call Read() to position on the first row override public bool Read() { @@ -4174,6 +4238,7 @@ private void AssertReaderState(bool requireData, bool permitAsync, int? columnIn } } + /// public override Task NextResultAsync(CancellationToken cancellationToken) { TaskCompletionSource source = new TaskCompletionSource(); @@ -4457,6 +4522,7 @@ private Task GetBytesAsyncReadDataStage(int i, byte[] buffer, int index, in return null; } + /// public override Task ReadAsync(CancellationToken cancellationToken) { if (IsClosed) @@ -4611,6 +4677,7 @@ public override Task ReadAsync(CancellationToken cancellationToken) return InvokeRetryable(moreFunc, source, registration); } + /// override public Task IsDBNullAsync(int i, CancellationToken cancellationToken) { try @@ -4735,6 +4802,7 @@ override public Task IsDBNullAsync(int i, CancellationToken cancellationTo } } + /// override public Task GetFieldValueAsync(int i, CancellationToken cancellationToken) { try @@ -5160,6 +5228,7 @@ private void SwitchToAsyncWithoutSnapshot() _stateObj._asyncReadWithoutSnapshot = true; } + /// public ReadOnlyCollection GetColumnSchema() { SqlStatistics statistics = null; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs index 703de213df..3bd4c38498 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -24,6 +24,7 @@ namespace Microsoft.Data.SqlClient { + /// public class SqlDataReader : DbDataReader, IDataReader { @@ -144,6 +145,7 @@ internal SqlCommand Command } } + /// protected SqlConnection Connection { get @@ -154,6 +156,7 @@ protected SqlConnection Connection public SensitivityClassification SensitivityClassification { get; internal set; } + /// override public int Depth { get @@ -167,6 +170,7 @@ override public int Depth } } + /// // fields/attributes collection override public int FieldCount { @@ -190,6 +194,7 @@ override public int FieldCount } } + /// override public bool HasRows { get @@ -207,6 +212,7 @@ override public bool HasRows } } + /// override public bool IsClosed { get @@ -397,6 +403,7 @@ internal virtual SmiExtendedMetaData[] GetInternalSmiMetaData() return metaDataReturn; } + /// override public int RecordsAffected { get @@ -436,7 +443,7 @@ internal MultiPartTableName[] TableNames _tableNames = value; } } - + /// override public int VisibleFieldCount { get @@ -454,6 +461,7 @@ override public int VisibleFieldCount } } + /// // this operator override public object this[int i] { @@ -463,6 +471,7 @@ override public object this[int i] } } + /// override public object this[string name] { get @@ -919,6 +928,7 @@ private void CleanPartialReadReliable() } } + /// override public void Close() { SqlStatistics statistics = null; @@ -1343,6 +1353,7 @@ private bool TryConsumeMetaData() return true; } + /// override public string GetDataTypeName(int i) { SqlStatistics statistics = null; @@ -1419,11 +1430,13 @@ virtual internal SqlBuffer.StorageType GetVariantInternalStorageType(int i) return _data[i].VariantInternalStorageType; } + /// override public IEnumerator GetEnumerator() { return new DbEnumerator(this, IsCommandBehavior(CommandBehavior.CloseConnection)); } + /// override public Type GetFieldType(int i) { SqlStatistics statistics = null; @@ -1526,6 +1539,7 @@ virtual internal int GetLocaleId(int i) return lcid; } + /// override public string GetName(int i) { CheckMetaDataIsReady(columnIndex: i); @@ -1534,6 +1548,7 @@ override public string GetName(int i) return _metaData[i].column; } + /// override public Type GetProviderSpecificFieldType(int i) { SqlStatistics statistics = null; @@ -1605,6 +1620,7 @@ private Type GetProviderSpecificFieldTypeInternal(_SqlMetaData metaData) return providerSpecificFieldType; } + /// // named field access override public int GetOrdinal(string name) { @@ -1625,16 +1641,19 @@ override public int GetOrdinal(string name) } } + /// override public object GetProviderSpecificValue(int i) { return GetSqlValue(i); } + /// override public int GetProviderSpecificValues(object[] values) { return GetSqlValues(values); } + /// override public DataTable GetSchemaTable() { SqlStatistics statistics = null; @@ -1666,12 +1685,14 @@ override public DataTable GetSchemaTable() } } + /// override public bool GetBoolean(int i) { ReadColumn(i); return _data[i].Boolean; } + /// virtual public XmlReader GetXmlReader(int i) { // NOTE: sql_variant can not contain a XML data type: http://msdn.microsoft.com/en-us/library/ms173829.aspx @@ -1711,6 +1732,7 @@ virtual public XmlReader GetXmlReader(int i) } } + /// override public Stream GetStream(int i) { CheckDataIsReady(columnIndex: i, methodName: "GetStream"); @@ -1758,12 +1780,14 @@ override public Stream GetStream(int i) } } + /// override public byte GetByte(int i) { ReadColumn(i); return _data[i].Byte; } + /// override public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length) { SqlStatistics statistics = null; @@ -2192,6 +2216,7 @@ internal bool TryGetBytesInternalSequential(int i, byte[] buffer, int index, int } } + /// override public TextReader GetTextReader(int i) { CheckDataIsReady(columnIndex: i, methodName: "GetTextReader"); @@ -2261,12 +2286,14 @@ override public TextReader GetTextReader(int i) } } + /// [EditorBrowsableAttribute(EditorBrowsableState.Never)] // MDAC 69508 override public char GetChar(int i) { throw ADP.NotSupported(); } + /// override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length) { SqlStatistics statistics = null; @@ -2606,12 +2633,14 @@ internal long GetStreamingXmlChars(int i, long dataIndex, char[] buffer, int buf return cnt; } + /// [EditorBrowsableAttribute(EditorBrowsableState.Never)] // MDAC 69508 IDataReader IDataRecord.GetData(int i) { throw ADP.NotSupported(); } + /// override public DateTime GetDateTime(int i) { ReadColumn(i); @@ -2633,66 +2662,77 @@ override public DateTime GetDateTime(int i) return dt; } + /// override public Decimal GetDecimal(int i) { ReadColumn(i); return _data[i].Decimal; } + /// override public double GetDouble(int i) { ReadColumn(i); return _data[i].Double; } + /// override public float GetFloat(int i) { ReadColumn(i); return _data[i].Single; } + /// override public Guid GetGuid(int i) { ReadColumn(i); return _data[i].SqlGuid.Value; } + /// override public Int16 GetInt16(int i) { ReadColumn(i); return _data[i].Int16; } + /// override public Int32 GetInt32(int i) { ReadColumn(i); return _data[i].Int32; } + /// override public Int64 GetInt64(int i) { ReadColumn(i); return _data[i].Int64; } + /// virtual public SqlBoolean GetSqlBoolean(int i) { ReadColumn(i); return _data[i].SqlBoolean; } + /// virtual public SqlBinary GetSqlBinary(int i) { ReadColumn(i, setTimeout: true, allowPartiallyReadColumn: true); return _data[i].SqlBinary; } + /// virtual public SqlByte GetSqlByte(int i) { ReadColumn(i); return _data[i].SqlByte; } + /// virtual public SqlBytes GetSqlBytes(int i) { ReadColumn(i); @@ -2700,6 +2740,7 @@ virtual public SqlBytes GetSqlBytes(int i) return new SqlBytes(data); } + /// virtual public SqlChars GetSqlChars(int i) { ReadColumn(i); @@ -2716,60 +2757,70 @@ virtual public SqlChars GetSqlChars(int i) return new SqlChars(data); } + /// virtual public SqlDateTime GetSqlDateTime(int i) { ReadColumn(i); return _data[i].SqlDateTime; } + /// virtual public SqlDecimal GetSqlDecimal(int i) { ReadColumn(i); return _data[i].SqlDecimal; } + /// virtual public SqlGuid GetSqlGuid(int i) { ReadColumn(i); return _data[i].SqlGuid; } + /// virtual public SqlDouble GetSqlDouble(int i) { ReadColumn(i); return _data[i].SqlDouble; } + /// virtual public SqlInt16 GetSqlInt16(int i) { ReadColumn(i); return _data[i].SqlInt16; } + /// virtual public SqlInt32 GetSqlInt32(int i) { ReadColumn(i); return _data[i].SqlInt32; } + /// virtual public SqlInt64 GetSqlInt64(int i) { ReadColumn(i); return _data[i].SqlInt64; } + /// virtual public SqlMoney GetSqlMoney(int i) { ReadColumn(i); return _data[i].SqlMoney; } + /// virtual public SqlSingle GetSqlSingle(int i) { ReadColumn(i); return _data[i].SqlSingle; } + /// // UNDONE: need non-unicode SqlString support virtual public SqlString GetSqlString(int i) { @@ -2783,6 +2834,7 @@ virtual public SqlString GetSqlString(int i) return _data[i].SqlString; } + /// virtual public SqlXml GetSqlXml(int i) { ReadColumn(i); @@ -2813,6 +2865,7 @@ virtual public SqlXml GetSqlXml(int i) return sx; } + /// virtual public object GetSqlValue(int i) { SqlStatistics statistics = null; @@ -2898,6 +2951,7 @@ private object GetSqlValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met } } + /// virtual public int GetSqlValues(object[] values) { SqlStatistics statistics = null; @@ -2926,6 +2980,7 @@ virtual public int GetSqlValues(object[] values) } } + /// override public string GetString(int i) { ReadColumn(i); @@ -2939,6 +2994,7 @@ override public string GetString(int i) return _data[i].String; } + /// override public T GetFieldValue(int i) { SqlStatistics statistics = null; @@ -2955,6 +3011,7 @@ override public T GetFieldValue(int i) } } + /// override public object GetValue(int i) { SqlStatistics statistics = null; @@ -2971,6 +3028,7 @@ override public object GetValue(int i) } } + /// virtual public TimeSpan GetTimeSpan(int i) { ReadColumn(i); @@ -2992,6 +3050,7 @@ virtual public TimeSpan GetTimeSpan(int i) return t; } + /// virtual public DateTimeOffset GetDateTimeOffset(int i) { ReadColumn(i); @@ -3183,6 +3242,7 @@ private T GetFieldValueFromSqlBufferInternal(SqlBuffer data, _SqlMetaData met } } + /// override public int GetValues(object[] values) { SqlStatistics statistics = null; @@ -3469,6 +3529,7 @@ private bool IsRowToken(byte token) return TdsEnums.SQLROW == token || TdsEnums.SQLNBCROW == token; } + /// override public bool IsDBNull(int i) { if ((IsCommandBehavior(CommandBehavior.SequentialAccess)) && ((_sharedState._nextColumnHeaderToRead > i + 1) || (_lastColumnWithDataChunkRead > i))) @@ -3493,11 +3554,13 @@ override public bool IsDBNull(int i) return _data[i].IsNull; } + /// protected internal bool IsCommandBehavior(CommandBehavior condition) { return (condition == (condition & _commandBehavior)); } + /// override public bool NextResult() { if (_currentTask != null) @@ -3701,6 +3764,7 @@ private bool TryNextResult(out bool more) } } + /// // user must call Read() to position on the first row override public bool Read() { @@ -4692,6 +4756,7 @@ private void AssertReaderState(bool requireData, bool permitAsync, int? columnIn } } + /// public override Task NextResultAsync(CancellationToken cancellationToken) { IntPtr hscp; @@ -4991,6 +5056,7 @@ private Task GetBytesAsyncReadDataStage(int i, byte[] buffer, int index, in return null; } + /// public override Task ReadAsync(CancellationToken cancellationToken) { IntPtr hscp; @@ -5156,6 +5222,7 @@ public override Task ReadAsync(CancellationToken cancellationToken) } } + /// override public Task IsDBNullAsync(int i, CancellationToken cancellationToken) { @@ -5279,6 +5346,7 @@ override public Task IsDBNullAsync(int i, CancellationToken cancellationTo } } + /// override public Task GetFieldValueAsync(int i, CancellationToken cancellationToken) { From 58b081ee64902949902ae38ca2d597bee30cb8cf Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:10:31 -0700 Subject: [PATCH 07/19] add include tags for SqlDependency.xml --- .../Microsoft.Data.SqlClient/SqlDependency.xml | 8 ++++---- .../SqlClient/SqlConnectionStringBuilder.cs | 2 +- .../Microsoft/Data/SqlClient/SqlDependency.cs | 17 ++++++++++++----- .../SqlClient/SqlConnectionStringBuilder.cs | 2 +- .../Microsoft/Data/SqlClient/SqlDependency.cs | 18 ++++++++++++------ 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml index 7c9cc88cf0..4ec7523efe 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml @@ -127,7 +127,7 @@ ]]> - + Starts the listener for receiving dependency change notifications. - Stops a listener for a connection specified in a previous call. + Stops a listener for a connection specified in a previous call. Connection string for the instance of SQL Server that was used in a previous call. - Stops a listener for a connection specified in a previous call. + Stops a listener for a connection specified in a previous call. if the listener was completely stopped; if the was unbound from the listener, but there are is at least one other using the same listener. @@ -237,7 +237,7 @@ Connection string for the instance of SQL Server that was used in a previous call. The SQL Server Service Broker queue that was used in a previous call. - Stops a listener for a connection specified in a previous call. + Stops a listener for a connection specified in a previous call. if the listener was completely stopped; if the was unbound from the listener, but there is at least one other using the same listener. diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs index f5a51befbe..4f052fac9e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs @@ -232,7 +232,7 @@ public SqlConnectionStringBuilder(string connectionString) : base() } } - /// + /// public override object this[string keyword] { get diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs index 8a3691c2c4..b7807538bd 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -16,6 +16,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlDependency { // Private class encapsulating the user/identity information - either SQL Auth username or Windows identity. @@ -227,16 +228,18 @@ private static void InvokeCallback(object eventContextPair) private static readonly string s_assemblyName = (typeof(SqlDependencyProcessDispatcher)).Assembly.FullName; private static readonly string s_typeName = (typeof(SqlDependencyProcessDispatcher)).FullName; + /// // Constructors - public SqlDependency() : this(null, null, SQL.SqlDependencyTimeoutDefault) { } + /// public SqlDependency(SqlCommand command) : this(command, null, SQL.SqlDependencyTimeoutDefault) { } + /// public SqlDependency(SqlCommand command, string options, int timeout) { if (timeout < 0) @@ -255,9 +258,10 @@ public SqlDependency(SqlCommand command, string options, int timeout) } // Public Properties - + /// public bool HasChanges => _dependencyFired; + /// public string Id => _id; // Internal Properties @@ -273,7 +277,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) internal int Timeout => _timeout; // Events - + /// public event OnChangeEventHandler OnChange { // EventHandlers to be fired when dependency is notified. @@ -327,7 +331,7 @@ public event OnChangeEventHandler OnChange } // Public Methods - + /// public void AddCommandDependency(SqlCommand command) { // Adds command to dependency collection so we automatically create the SqlNotificationsRequest object @@ -343,12 +347,13 @@ public void AddCommandDependency(SqlCommand command) // Static Methods - public & internal // Static Start/Stop methods - + /// public static bool Start(string connectionString) { return Start(connectionString, null, true); } + /// public static bool Start(string connectionString, string queue) { return Start(connectionString, queue, false); @@ -466,11 +471,13 @@ internal static bool Start(string connectionString, string queue, bool useDefaul return result; } + /// public static bool Stop(string connectionString) { return Stop(connectionString, null, true, false); } + /// public static bool Stop(string connectionString, string queue) { return Stop(connectionString, queue, false, false); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs index 6d31b3064e..1dac6dc7bd 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs @@ -268,7 +268,7 @@ public SqlConnectionStringBuilder(string connectionString) : base() } } - /// + /// public override object this[string keyword] { get diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs index 788b9e5995..77a79630b1 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -21,7 +21,7 @@ namespace Microsoft.Data.SqlClient { - + /// public sealed class SqlDependency { @@ -298,20 +298,22 @@ internal int ObjectID } } + /// // ------------ // Constructors // ------------ - [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public SqlDependency() : this(null, null, SQL.SqlDependencyTimeoutDefault) { } + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public SqlDependency(SqlCommand command) : this(command, null, SQL.SqlDependencyTimeoutDefault) { } + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public SqlDependency(SqlCommand command, string options, int timeout) { @@ -346,7 +348,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) // ----------------- // Public Properties // ----------------- - + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlDependency_HasChanges) @@ -359,6 +361,7 @@ public bool HasChanges } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlDependency_Id) @@ -425,7 +428,7 @@ internal int Timeout // ------ // Events // ------ - + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlDependency_OnChange) @@ -505,7 +508,7 @@ public event OnChangeEventHandler OnChange // -------------- // Public Methods // -------------- - + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlDependency_AddCommandDependency) @@ -636,13 +639,14 @@ private static SqlDependencyProcessDispatcher GetDeserializedObject(BinaryFormat // ------------------------- // Static Start/Stop methods // ------------------------- - + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public static bool Start(string connectionString) { return Start(connectionString, null, true); } + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public static bool Start(string connectionString, string queue) { @@ -787,12 +791,14 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } } + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public static bool Stop(string connectionString) { return Stop(connectionString, null, true, false); } + /// [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public static bool Stop(string connectionString, string queue) { From 73f4511dd3ea51641a4496c41d11e58969477aa0 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:18:18 -0700 Subject: [PATCH 08/19] add include tags for SqlEnclaveAttestationParameters.xml --- .../SqlEnclaveAttestationParameters.cs | 12 +++------- .../SqlEnclaveAttestationParameters.cs | 23 ++++--------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs index ea381f57e7..6cc8a4d249 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs @@ -4,21 +4,15 @@ namespace Microsoft.Data.SqlClient { - /// - /// Encapsulates the information SqlClient sends to SQL Server to initiate the process of attesting and creating a secure session with the enclave, SQL Server uses for computations on columns protected using Always Encrypted. - /// + /// public partial class SqlEnclaveAttestationParameters { private readonly byte[] _input = null; - /// - /// Identifies an enclave attestation protocol. - /// + /// public int Protocol { get; } - /// - /// The information used to initiate the process of attesting the enclave. The format and the content of this information is specific to the attestation protocol. - /// + /// public byte[] GetInput() { return Clone(_input); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs index e5b7af8e17..224c191bd9 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.cs @@ -7,9 +7,7 @@ namespace Microsoft.Data.SqlClient { - /// - /// Encapsulates the information SqlClient sends to SQL Server to initiate the process of attesting and creating a secure session with the enclave, SQL Server uses for computations on columns protected using Always Encrypted. - /// + /// public class SqlEnclaveAttestationParameters { @@ -19,20 +17,14 @@ public class SqlEnclaveAttestationParameters private readonly byte[] _input; - /// - /// Identifies an enclave attestation protocol. - /// + /// public int Protocol { get; } - /// - /// A Diffie-Hellman algorithm encapsulating a key pair, SqlClient uses to establish a secure session with the enclave. - /// + /// public ECDiffieHellmanCng ClientDiffieHellmanKey { get; } - /// - /// The information used to initiate the process of attesting the enclave. The format and the content of this information is specific to the attestation protocol. - /// + /// public byte[] GetInput() { return Clone(_input); @@ -61,12 +53,7 @@ private byte[] Clone(byte[] arrayToClone) return returnValue; } - /// - /// Initializes a new instance of SqlEnclaveAttestationParameters. - /// - /// Identifies an enclave attestation protocol. - /// The input of the enclave attestation protocol. - /// A Diffie-Hellman algorithm encapsulating a client-side key pair. + /// public SqlEnclaveAttestationParameters(int protocol, byte[] input, ECDiffieHellmanCng clientDiffieHellmanKey) { if (null == clientDiffieHellmanKey) From b9a3071297bdb1327e8e146840ef4a53161b9c55 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:25:09 -0700 Subject: [PATCH 09/19] add include tags for SqlEnclaveSession.xml --- .../Data/SqlClient/SqlEnclaveSession.cs | 19 ++++--------------- .../Data/SqlClient/SqlEnclaveSession.cs | 19 ++++--------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs index 03736068de..f395be9e91 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs @@ -4,9 +4,7 @@ namespace Microsoft.Data.SqlClient { - /// - /// Encapsulates the state of a secure session between SqlClient and an enclave inside SQL Server, which can be used for computations on encrypted columns protected with Always Encrypted. - /// + /// public class SqlEnclaveSession { @@ -15,14 +13,10 @@ public class SqlEnclaveSession private readonly byte[] _sessionKey; - /// - /// A session id - /// + /// public long SessionId { get; } - /// - /// The symmetric key SqlClient uses to encrypt all the information it sends to the enclave using the session. - /// + /// public byte[] GetSessionKey() { return Clone(_sessionKey); @@ -46,12 +40,7 @@ private byte[] Clone(byte[] arrayToClone) return returnValue; } - /// - /// Creates a new session - /// - /// The symmetric key used to encrypt all the information sent using the session. - /// The session id. - /// The counter that helps prevent replay attacks and is incremented each time the session is retrieved from the cache. + /// public SqlEnclaveSession(byte[] sessionKey, long sessionId/*, long counter*/) { if (null == sessionKey) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs index 038678d36f..146ed70c27 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs @@ -5,9 +5,7 @@ namespace Microsoft.Data.SqlClient { - /// - /// Encapsulates the state of a secure session between SqlClient and an enclave inside SQL Server, which can be used for computations on encrypted columns protected with Always Encrypted. - /// + /// public class SqlEnclaveSession { @@ -16,14 +14,10 @@ public class SqlEnclaveSession private readonly byte[] _sessionKey; - /// - /// A session id - /// + /// public long SessionId { get; } - /// - /// The symmetric key SqlClient uses to encrypt all the information it sends to the enclave using the session. - /// + /// public byte[] GetSessionKey() { return Clone(_sessionKey); @@ -47,12 +41,7 @@ private byte[] Clone(byte[] arrayToClone) return returnValue; } - /// - /// Creates a new session - /// - /// The symmetric key used to encrypt all the information sent using the session. - /// The session id. - /// The counter that helps prevent replay attacks and is incremented each time the session is retrieved from the cache. + /// public SqlEnclaveSession(byte[] sessionKey, long sessionId/*, long counter*/) { if (null == sessionKey) From a05fcb51c9e489df946b8fc8264a0adf5e82cf7d Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:34:31 -0700 Subject: [PATCH 10/19] add include tags for SqlError.xml --- .../netcore/src/Microsoft/Data/SqlClient/SqlError.cs | 10 ++++++++++ .../netfx/src/Microsoft/Data/SqlClient/SqlError.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlError.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlError.cs index ddc4f8b6d8..15e313ad30 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlError.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlError.cs @@ -6,6 +6,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlError { private string _source = TdsEnums.SQL_PROVIDER_NAME; @@ -38,6 +39,7 @@ internal SqlError(int infoNumber, byte errorState, byte errorClass, string serve _exception = exception; } + /// // There is no exception stack included because the correct exception stack is only available // on SqlException, and to obtain that the SqlError would have to have backpointers all the // way back to SqlException. If the user needs a call stack, they can obtain it on SqlException. @@ -46,41 +48,49 @@ public override string ToString() return typeof(SqlError).ToString() + ": " + _message; // since this is sealed so we can change GetType to typeof } + /// public string Source { get { return _source; } } + /// public int Number { get { return _number; } } + /// public byte State { get { return _state; } } + /// public byte Class { get { return _errorClass; } } + /// public string Server { get { return _server; } } + /// public string Message { get { return _message; } } + /// public string Procedure { get { return _procedure; } } + /// public int LineNumber { get { return _lineNumber; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlError.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlError.cs index 08b09187b3..7033d7f5d4 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlError.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlError.cs @@ -6,6 +6,7 @@ namespace Microsoft.Data.SqlClient { + /// [Serializable] public sealed class SqlError { @@ -47,6 +48,7 @@ internal SqlError(int infoNumber, byte errorState, byte errorClass, string serve this.win32ErrorCode = 0; } + /// // bug fix - MDAC #49280 - SqlError does not implement ToString(); // I did not include an exception stack because the correct exception stack is only available // on SqlException, and to obtain that the SqlError would have to have backpointers all the @@ -57,42 +59,50 @@ public override string ToString() return typeof(SqlError).ToString() + ": " + this.message; // since this is sealed so we can change GetType to typeof } + /// // bug fix - MDAC #48965 - missing source of exception public string Source { get { return this.source; } } + /// public int Number { get { return this.number; } } + /// public byte State { get { return this.state; } } + /// public byte Class { get { return this.errorClass; } } + /// public string Server { get { return this.server; } } + /// public string Message { get { return this.message; } } + /// public string Procedure { get { return this.procedure; } } + /// public int LineNumber { get { return this.lineNumber; } From 06656335a9129b6de87f2ebcbe6ddeb90220b437 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:49:13 -0700 Subject: [PATCH 11/19] add include tags for SqlErrorCollection.xml and SqlException.xml --- .../Microsoft/Data/SqlClient/SqlErrorCollection.cs | 8 ++++++++ .../src/Microsoft/Data/SqlClient/SqlException.cs | 13 ++++++++++++- .../Microsoft/Data/SqlClient/SqlErrorCollection.cs | 8 ++++++++ .../src/Microsoft/Data/SqlClient/SqlException.cs | 12 ++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs index ba2f8331c9..3bf984d162 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs @@ -8,6 +8,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlErrorCollection : ICollection { // Ideally this would be typed as List, but that would make the non-generic @@ -19,18 +20,25 @@ public sealed class SqlErrorCollection : ICollection internal SqlErrorCollection() { } + /// public void CopyTo(Array array, int index) => ((ICollection)_errors).CopyTo(array, index); + /// public void CopyTo(SqlError[] array, int index) => _errors.CopyTo(array, index); + /// public int Count => _errors.Count; + /// object ICollection.SyncRoot => this; + /// bool ICollection.IsSynchronized => false; + /// public SqlError this[int index] => (SqlError)_errors[index]; + /// public IEnumerator GetEnumerator() => _errors.GetEnumerator(); internal void Add(SqlError error) => _errors.Add(error); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlException.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlException.cs index 256af263bc..836ad3e185 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlException.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlException.cs @@ -12,6 +12,7 @@ namespace Microsoft.Data.SqlClient { + /// [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed partial class SqlException : System.Data.Common.DbException @@ -43,6 +44,7 @@ private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc) } } + /// public override void GetObjectData(SerializationInfo si, StreamingContext context) { base.GetObjectData(si, context); @@ -61,6 +63,7 @@ public override void GetObjectData(SerializationInfo si, StreamingContext contex } } + /// // runtime will call even if private... public SqlErrorCollection Errors { @@ -74,6 +77,7 @@ public SqlErrorCollection Errors } } + /// public Guid ClientConnectionId { get @@ -82,42 +86,49 @@ public Guid ClientConnectionId } } - + /// public byte Class { get { return Errors.Count > 0 ? this.Errors[0].Class : default; } } + /// public int LineNumber { get { return Errors.Count > 0 ? Errors[0].LineNumber : default; } } + /// public int Number { get { return Errors.Count > 0 ? Errors[0].Number : default; } } + /// public string Procedure { get { return Errors.Count > 0 ? Errors[0].Procedure : default; } } + /// public string Server { get { return Errors.Count > 0 ? Errors[0].Server : default; } } + /// public byte State { get { return Errors.Count > 0 ? Errors[0].State : default; } } + /// override public string Source { get { return Errors.Count > 0 ? Errors[0].Source : default; } } + /// public override string ToString() { StringBuilder sb = new StringBuilder(base.ToString()); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs index 142b12eb32..c49d345266 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlErrorCollection.cs @@ -8,6 +8,7 @@ namespace Microsoft.Data.SqlClient { + /// [Serializable, ListBindable(false)] public sealed class SqlErrorCollection : ICollection { @@ -18,31 +19,37 @@ internal SqlErrorCollection() { } + /// public void CopyTo(Array array, int index) { this.errors.CopyTo(array, index); } + /// public void CopyTo(SqlError[] array, int index) { this.errors.CopyTo(array, index); } + /// public int Count { get { return this.errors.Count; } } + /// object System.Collections.ICollection.SyncRoot { // MDAC 68481 get { return this; } } + /// bool System.Collections.ICollection.IsSynchronized { // MDAC 68481 get { return false; } } + /// public SqlError this[int index] { get @@ -51,6 +58,7 @@ public SqlError this[int index] } } + /// public IEnumerator GetEnumerator() { return errors.GetEnumerator(); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlException.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlException.cs index 3378002da0..544a0396c3 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlException.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlException.cs @@ -13,6 +13,7 @@ namespace Microsoft.Data.SqlClient { + /// [Serializable] public sealed class SqlException : System.Data.Common.DbException { @@ -46,6 +47,7 @@ private SqlException(SerializationInfo si, StreamingContext sc) : base(si, sc) } + /// override public void GetObjectData(SerializationInfo si, StreamingContext context) { if (null == si) @@ -57,6 +59,7 @@ override public void GetObjectData(SerializationInfo si, StreamingContext contex base.GetObjectData(si, context); } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Content) ] @@ -72,6 +75,7 @@ public SqlErrorCollection Errors } } + /// public Guid ClientConnectionId { get @@ -86,41 +90,49 @@ private bool ShouldSerializeErrors() return ((null != _errors) && (0 < _errors.Count)); } + /// public byte Class { get { return this.Errors[0].Class; } } + /// public int LineNumber { get { return this.Errors[0].LineNumber; } } + /// public int Number { get { return this.Errors[0].Number; } } + /// public string Procedure { get { return this.Errors[0].Procedure; } } + /// public string Server { get { return this.Errors[0].Server; } } + /// public byte State { get { return this.Errors[0].State; } } + /// override public string Source { get { return this.Errors[0].Source; } } + /// public override string ToString() { StringBuilder sb = new StringBuilder(base.ToString()); From 4102f638967a7b6974dee5df5b9abe0ff2bc7e88 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 15:53:40 -0700 Subject: [PATCH 12/19] add include tags for SqlInfoMessageEventArgs.xml and SqlInfoMessageEventHandler.xml --- .../src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs | 5 +++++ .../Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs | 6 +----- .../src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs | 6 +++++- .../Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs | 7 +------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs index 0f10d7df2a..5c1aefb61b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs @@ -4,6 +4,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlInfoMessageEventArgs : System.EventArgs { private SqlException _exception; @@ -13,6 +14,7 @@ internal SqlInfoMessageEventArgs(SqlException exception) _exception = exception; } + /// public SqlErrorCollection Errors { get { return _exception.Errors; } @@ -23,16 +25,19 @@ private bool ShouldSerializeErrors() return (null != _exception) && (0 < _exception.Errors.Count); } + /// public string Message { get { return _exception.Message; } } + /// public string Source { get { return _exception.Source; } } + /// override public string ToString() { return Message; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs index 69b684c00a..893f3acf60 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs @@ -4,10 +4,6 @@ namespace Microsoft.Data.SqlClient { - /// - /// - /// Represents the method that will handle the event of a . - /// - /// + /// public delegate void SqlInfoMessageEventHandler(object sender, SqlInfoMessageEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs index 560a63de32..d191d6d2af 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEvent.cs @@ -4,7 +4,7 @@ namespace Microsoft.Data.SqlClient { - + /// public sealed class SqlInfoMessageEventArgs : System.EventArgs { private SqlException exception; @@ -14,6 +14,7 @@ internal SqlInfoMessageEventArgs(SqlException exception) this.exception = exception; } + /// public SqlErrorCollection Errors { get { return exception.Errors; } @@ -25,16 +26,19 @@ private bool ShouldSerializeErrors() return (null != exception) && (0 < exception.Errors.Count); } + /// public string Message { // MDAC 68482 get { return exception.Message; } } + /// public string Source { // MDAC 68482 get { return exception.Source; } } + /// override public string ToString() { // MDAC 68482 return Message; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs index 65283e4c79..893f3acf60 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInfoMessageEventHandler.cs @@ -4,11 +4,6 @@ namespace Microsoft.Data.SqlClient { - - /// - /// - /// Represents the method that will handle the event of a . - /// - /// + /// public delegate void SqlInfoMessageEventHandler(object sender, SqlInfoMessageEventArgs e); } From 009b287036382e2c8d16a1323c28e92f9c3f4c55 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 16:09:23 -0700 Subject: [PATCH 13/19] add inclue tags for SqlNotification xmls --- .../SqlClient/SqlNotificationEventArgs.cs | 5 +++++ .../Data/SqlClient/SqlNotificationInfo.cs | 21 ++++++++++++++++++- .../Data/SqlClient/SqlNotificationSource.cs | 13 +++++++++++- .../Data/SqlClient/SqlNotificationType.cs | 5 ++++- .../SqlClient/SqlNotificationEventArgs.cs | 5 +++++ .../Data/SqlClient/SqlNotificationInfo.cs | 21 ++++++++++++++++++- .../Data/SqlClient/SqlNotificationSource.cs | 13 +++++++++++- .../Data/SqlClient/SqlNotificationType.cs | 5 ++++- 8 files changed, 82 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs index f140033811..3a391642b6 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs @@ -6,12 +6,14 @@ namespace Microsoft.Data.SqlClient { + /// public class SqlNotificationEventArgs : EventArgs { private SqlNotificationType _type; private SqlNotificationInfo _info; private SqlNotificationSource _source; + /// public SqlNotificationEventArgs(SqlNotificationType type, SqlNotificationInfo info, SqlNotificationSource source) { _info = info; @@ -19,10 +21,13 @@ public SqlNotificationEventArgs(SqlNotificationType type, SqlNotificationInfo in _type = type; } + /// public SqlNotificationType Type => _type; + /// public SqlNotificationInfo Info => _info; + /// public SqlNotificationSource Source => _source; internal static SqlNotificationEventArgs s_notifyError = new SqlNotificationEventArgs(SqlNotificationType.Subscribe, SqlNotificationInfo.Error, SqlNotificationSource.Object); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs index b6fa8d7d0f..503b17a65a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs @@ -4,28 +4,47 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationInfo { + /// Truncate = 0, + /// Insert = 1, + /// Update = 2, + /// Delete = 3, + /// Drop = 4, + /// Alter = 5, + /// Restart = 6, + /// Error = 7, + /// Query = 8, + /// Invalid = 9, + /// Options = 10, + /// Isolation = 11, + /// Expired = 12, + /// Resource = 13, + /// PreviousFire = 14, + /// TemplateLimit = 15, + /// Merge = 16, - + /// // use negative values for client-only-generated values Unknown = -1, + /// AlreadyChanged = -2 } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs index 4c0e88d3a2..15439172e4 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs @@ -4,20 +4,31 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationSource { + /// Data = 0, + /// Timeout = 1, + /// Object = 2, + /// Database = 3, + /// System = 4, + /// Statement = 5, + /// Environment = 6, + /// Execution = 7, + /// Owner = 8, - + /// // use negative values for client-only-generated values Unknown = -1, + /// Client = -2 } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationType.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationType.cs index b10a2ff1cf..e38dd4de93 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationType.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlNotificationType.cs @@ -4,11 +4,14 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationType { + /// Change = 0, + /// Subscribe = 1, - + /// // use negative values for client-only-generated values Unknown = -1 } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs index ab8a59be22..1c28c64859 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationEventArgs.cs @@ -6,12 +6,14 @@ namespace Microsoft.Data.SqlClient { + /// public class SqlNotificationEventArgs : EventArgs { private SqlNotificationType _type; private SqlNotificationInfo _info; private SqlNotificationSource _source; + /// public SqlNotificationEventArgs(SqlNotificationType type, SqlNotificationInfo info, SqlNotificationSource source) { _info = info; @@ -19,6 +21,7 @@ public SqlNotificationEventArgs(SqlNotificationType type, SqlNotificationInfo in _type = type; } + /// public SqlNotificationType Type { get @@ -27,6 +30,7 @@ public SqlNotificationType Type } } + /// public SqlNotificationInfo Info { get @@ -35,6 +39,7 @@ public SqlNotificationInfo Info } } + /// public SqlNotificationSource Source { get diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs index b6fa8d7d0f..503b17a65a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationInfo.cs @@ -4,28 +4,47 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationInfo { + /// Truncate = 0, + /// Insert = 1, + /// Update = 2, + /// Delete = 3, + /// Drop = 4, + /// Alter = 5, + /// Restart = 6, + /// Error = 7, + /// Query = 8, + /// Invalid = 9, + /// Options = 10, + /// Isolation = 11, + /// Expired = 12, + /// Resource = 13, + /// PreviousFire = 14, + /// TemplateLimit = 15, + /// Merge = 16, - + /// // use negative values for client-only-generated values Unknown = -1, + /// AlreadyChanged = -2 } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs index 4c0e88d3a2..15439172e4 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationSource.cs @@ -4,20 +4,31 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationSource { + /// Data = 0, + /// Timeout = 1, + /// Object = 2, + /// Database = 3, + /// System = 4, + /// Statement = 5, + /// Environment = 6, + /// Execution = 7, + /// Owner = 8, - + /// // use negative values for client-only-generated values Unknown = -1, + /// Client = -2 } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationType.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationType.cs index b10a2ff1cf..e38dd4de93 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationType.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlNotificationType.cs @@ -4,11 +4,14 @@ namespace Microsoft.Data.SqlClient { + /// public enum SqlNotificationType { + /// Change = 0, + /// Subscribe = 1, - + /// // use negative values for client-only-generated values Unknown = -1 } From b7144fa802e66c8af0aa21b6359995379eba7a0b Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 16 Sep 2019 16:37:26 -0700 Subject: [PATCH 14/19] add newline at the end of each xml file --- .../SqlConnectionColumnEncryptionSetting.xml | 2 +- .../Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml | 2 +- .../SqlEnclaveAttestationParameters.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlError.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlException.xml | 2 +- .../Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml | 2 +- .../Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml | 2 +- .../Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml | 2 +- .../Microsoft.Data.SqlClient/SqlParameterCollection.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml | 2 +- .../Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml | 2 +- doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml index ccc3359d3e..9bd5fd1cd2 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionColumnEncryptionSetting.xml @@ -12,4 +12,4 @@ Enables Always Encrypted functionality for the connection. Query parameters that correspond to encrypted columns will be transparently encrypted and query results from encrypted columns will be transparently decrypted. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml index 85f365a9b1..3f82a469ae 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml @@ -888,4 +888,4 @@ Unable to retrieve value for null key. To set the value to null, use . - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml index c2389f407a..82a20866f7 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlCredential.xml @@ -84,4 +84,4 @@ conn.Open(); ADO.NET Overview - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml index 77b67143e8..b259a78f3a 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDataAdapter.xml @@ -498,4 +498,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml index 344880d6a6..85eddaead4 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml @@ -1209,4 +1209,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml index 4ec7523efe..5907e724d3 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlDependency.xml @@ -254,4 +254,4 @@ And underlying **SqlClient** exception occurred. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml index 36192bec3f..295d8b25e8 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml @@ -30,4 +30,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml index 918ad0ab81..504e996459 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml @@ -26,4 +26,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml index 24cf205e4b..e70773c11d 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlError.xml @@ -204,4 +204,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml index 68e08cae0b..880e397d1c 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlErrorCollection.xml @@ -111,4 +111,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml index 63849e6dfc..12494bdeda 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlException.xml @@ -364,4 +364,4 @@ End Module - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml index dc949e9e27..f7965a43cd 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventArgs.xml @@ -49,4 +49,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml index c6c980f0e9..54b1301450 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlInfoMessageEventHandler.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml index 659e412468..0e8a69c33b 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationEventArgs.xml @@ -38,4 +38,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml index fb7c491731..979682d203 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationInfo.xml @@ -70,4 +70,4 @@ Data was changed by an UPDATE statement. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml index 35d6f64cf5..95719bd6c2 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationSource.xml @@ -48,4 +48,4 @@ Used when the source option sent by the server was not recognized by the client. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml index 38025201f6..ce1afde79e 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlNotificationType.xml @@ -22,4 +22,4 @@ Used when the type option sent by the server was not recognized by the client. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml index 165ed733a4..b9ebdb2be4 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml @@ -650,4 +650,4 @@ FieldName = @OriginalFieldName - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml index 760a49126c..17f3042cef 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml @@ -363,4 +363,4 @@ parameters.Add("@pname", Convert.ToInt32(0)); To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml index 661945ece4..b0e8de877a 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventArgs.xml @@ -57,4 +57,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml index e0d2fbaa4e..51bd12d028 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatedEventHandler.xml @@ -17,4 +17,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml index cf7cd3120f..d70628936a 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventArgs.xml @@ -62,4 +62,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml index e17361513b..7a31b33411 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowUpdatingEventHandler.xml @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml index 1ae9016785..d655582980 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventArgs.xml @@ -48,4 +48,4 @@ - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml index 9033f0032d..325fcf10f1 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlRowsCopiedEventHandler.xml @@ -8,4 +8,4 @@ To be added. - \ No newline at end of file + diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml index 7dec32ea65..0ff2fc8f87 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml @@ -184,4 +184,4 @@ The connection is broken. - \ No newline at end of file + From fce12dbd300365812156baa42e7bee86cd406c96 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 17 Sep 2019 10:00:13 -0700 Subject: [PATCH 15/19] add include tags for SqlParameter and SqlParameterCollection.xml --- .../Microsoft.Data.SqlClient/SqlParameter.xml | 6 ++-- .../SqlParameterCollection.xml | 18 +++++------ .../Microsoft/Data/SqlClient/SqlParameter.cs | 27 +++++++++++++++++ .../Data/SqlClient/SqlParameterCollection.cs | 17 +++++++++++ .../SqlClient/SqlParameterCollectionHelper.cs | 19 +++++++++++- .../Data/SqlClient/SqlParameterHelper.cs | 8 ++++- .../SqlParameterCollectionHelper.cs | 21 +++++++++++++ .../Data/ProviderBase/SqlParameterHelper.cs | 8 +++++ .../Microsoft/Data/SqlClient/SqlParameter.cs | 30 +++++++++++++++++-- .../Data/SqlClient/SqlParameterCollection.cs | 16 ++++++++++ 10 files changed, 154 insertions(+), 16 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml index b9ebdb2be4..bd89b57a58 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameter.xml @@ -115,7 +115,7 @@ If you do not perform this conversion, the compiler assumes that you are trying The name of the parameter to map. One of the values. The length of the parameter. - The name of the source column () if this is used in a call to . + The name of the source column () if this is used in a call to . Initializes a new instance of the class that uses the parameter name, the , the size, and the source column name. if the value of the field can be null; otherwise, . The total number of digits to the left and right of the decimal point to which is resolved. The total number of decimal places to which is resolved. - The name of the source column () if this is used in a call to . + The name of the source column () if this is used in a call to . One of the values. An that is the value of the . Initializes a new instance of the class that uses the parameter name, the type of the parameter, the size of the parameter, a , the precision of the parameter, the scale of the parameter, the source column, a to use, and the value of the parameter. @@ -171,7 +171,7 @@ If you do not perform this conversion, the compiler assumes that you are trying One of the values. The total number of digits to the left and right of the decimal point to which is resolved. The total number of decimal places to which is resolved. - The name of the source column () if this is used in a call to . + The name of the source column () if this is used in a call to . One of the values. if the source column is nullable; if it is not. diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml index 17f3042cef..b8cec8c266 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlParameterCollection.xml @@ -46,7 +46,7 @@ The index of the new object. To be added. - + The name of the parameter. One of the values. Adds a to the given the parameter name and the data type. @@ -59,7 +59,7 @@ ]]> - + The name of the to add to the collection. A . @@ -84,7 +84,7 @@ parameters.Add("@pname", Convert.ToInt32(0)); The specified in the parameter is already added to this or another . The parameter is null. - + The name of the parameter. The of the to add to the collection. The size as an . @@ -103,12 +103,12 @@ parameters.Add("@pname", Convert.ToInt32(0)); ]]> - - + + The name of the parameter. One of the values. The column length. - The name of the source column () if this is used in a call to . + The name of the source column () if this is used in a call to . Adds a to the with the parameter name, the data type, and the column length. A new object. @@ -119,7 +119,7 @@ parameters.Add("@pname", Convert.ToInt32(0)); ]]> - + Adds elements to the end of the . @@ -345,12 +345,12 @@ parameters.Add("@pname", Convert.ToInt32(0)); Removes the from the at the specified parameter name. To be added. - + To be added. To be added. To be added. To be added. - + To be added. To be added. diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs index 279b518af2..8e144da346 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs @@ -70,6 +70,7 @@ internal XmlDataFeed(XmlReader source) } } + /// [TypeConverter(typeof(SqlParameterConverter))] public sealed partial class SqlParameter : DbParameter, IDbDataParameter, ICloneable { @@ -118,16 +119,19 @@ public sealed partial class SqlParameter : DbParameter, IDbDataParameter, IClone private DataRowVersion _sourceVersion; + /// public SqlParameter() : base() { } + /// public SqlParameter(string parameterName, SqlDbType dbType) : this() { this.ParameterName = parameterName; this.SqlDbType = dbType; } + /// public SqlParameter(string parameterName, object value) : this() { Debug.Assert(!(value is SqlDbType), "use SqlParameter(string, SqlDbType)"); @@ -136,6 +140,7 @@ public SqlParameter(string parameterName, object value) : this() this.Value = value; } + /// public SqlParameter(string parameterName, SqlDbType dbType, int size) : this() { this.ParameterName = parameterName; @@ -143,6 +148,7 @@ public SqlParameter(string parameterName, SqlDbType dbType, int size) : this() this.Size = size; } + /// public SqlParameter(string parameterName, SqlDbType dbType, int size, string sourceColumn) : this() { this.ParameterName = parameterName; @@ -151,6 +157,7 @@ public SqlParameter(string parameterName, SqlDbType dbType, int size, string sou this.SourceColumn = sourceColumn; } + /// public SqlParameter( string parameterName, SqlDbType dbType, @@ -172,6 +179,7 @@ object value this.Value = value; } + /// public SqlParameter( string parameterName, SqlDbType dbType, @@ -228,6 +236,7 @@ internal SqlCollation Collation } } + /// public SqlCompareOptions CompareInfo { // Bits 21 through 25 represent the CompareInfo @@ -262,6 +271,7 @@ public SqlCompareOptions CompareInfo } } + /// public string XmlSchemaCollectionDatabase { get @@ -275,6 +285,7 @@ public string XmlSchemaCollectionDatabase } } + /// public string XmlSchemaCollectionOwningSchema { get @@ -288,6 +299,7 @@ public string XmlSchemaCollectionOwningSchema } } + /// public string XmlSchemaCollectionName { get @@ -301,12 +313,14 @@ public string XmlSchemaCollectionName } } + /// public bool ForceColumnEncryption { get; set; } + /// public override DbType DbType { get @@ -328,6 +342,7 @@ public override DbType DbType } } + /// public override void ResetDbType() { ResetSqlDbType(); @@ -343,6 +358,7 @@ internal MetaType InternalMetaType set { _internalMetaType = value; } } + /// public int LocaleId { // Lowest 20 bits represent LocaleId @@ -563,6 +579,7 @@ internal bool ParameterIsSqlType } } + /// public override string ParameterName { get @@ -602,6 +619,7 @@ internal string ParameterNameFixed } } + /// [DefaultValue((byte)0)] public new byte Precision { @@ -647,6 +665,7 @@ private bool ShouldSerializePrecision() return (0 != _precision); } + /// [DefaultValue((byte)0)] public new byte Scale { @@ -689,6 +708,7 @@ private bool ShouldSerializeScale() return (0 != _scale); // V1.0 compat, ignore _hasScale } + /// [DbProviderSpecificTypeProperty(true)] public SqlDbType SqlDbType { @@ -717,6 +737,7 @@ private bool ShouldSerializeSqlDbType() return (null != _metaType); } + /// public void ResetSqlDbType() { if (null != _metaType) @@ -726,6 +747,7 @@ public void ResetSqlDbType() } } + /// public object SqlValue { get @@ -772,6 +794,7 @@ public object SqlValue } } + /// public string UdtTypeName { get @@ -785,6 +808,7 @@ public string UdtTypeName } } + /// public string TypeName { get @@ -798,6 +822,7 @@ public string TypeName } } + /// [TypeConverter(typeof(StringConverter))] public override object Value { @@ -967,6 +992,7 @@ internal int GetActualSize() return _actualSize; } + /// object ICloneable.Clone() { return new SqlParameter(this); @@ -1189,6 +1215,7 @@ private void CloneHelper(SqlParameter destination) destination.ForceColumnEncryption = ForceColumnEncryption; } + /// public override DataRowVersion SourceVersion { get diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs index 0b7d962378..6ad3054bec 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs @@ -8,6 +8,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed partial class SqlParameterCollection : DbParameterCollection { private bool _isDirty; @@ -28,8 +29,11 @@ internal bool IsDirty _isDirty = value; } } + /// public override bool IsFixedSize => ((System.Collections.IList)InnerList).IsFixedSize; + /// public override bool IsReadOnly => ((System.Collections.IList)InnerList).IsReadOnly; + /// new public SqlParameter this[int index] { get @@ -42,6 +46,7 @@ internal bool IsDirty } } + /// new public SqlParameter this[string parameterName] { get @@ -54,57 +59,68 @@ internal bool IsDirty } } + /// public SqlParameter Add(SqlParameter value) { Add((object)value); return value; } + /// public SqlParameter AddWithValue(string parameterName, object value) { // 79027 return Add(new SqlParameter(parameterName, value)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType) { return Add(new SqlParameter(parameterName, sqlDbType)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size) { return Add(new SqlParameter(parameterName, sqlDbType, size)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size, string sourceColumn) { return Add(new SqlParameter(parameterName, sqlDbType, size, sourceColumn)); } + /// public void AddRange(SqlParameter[] values) { AddRange((Array)values); } + /// override public bool Contains(string value) { // WebData 97349 return (-1 != IndexOf(value)); } + /// public bool Contains(SqlParameter value) { return (-1 != IndexOf(value)); } + /// public void CopyTo(SqlParameter[] array, int index) { CopyTo((Array)array, index); } + /// public int IndexOf(SqlParameter value) { return IndexOf((object)value); } + /// public void Insert(int index, SqlParameter value) { Insert(index, (object)value); @@ -115,6 +131,7 @@ private void OnChange() IsDirty = true; } + /// public void Remove(SqlParameter value) { Remove((object)value); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollectionHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollectionHelper.cs index 7d43f296da..aafbc5d19d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterCollectionHelper.cs @@ -15,6 +15,7 @@ public sealed partial class SqlParameterCollection : DbParameterCollection { private List _items; + /// override public int Count { get @@ -38,7 +39,7 @@ private List InnerList } } - + /// override public object SyncRoot { get @@ -47,6 +48,7 @@ override public object SyncRoot } } + /// override public int Add(object value) { OnChange(); @@ -56,6 +58,7 @@ override public int Add(object value) return Count - 1; } + /// override public void AddRange(System.Array values) { OnChange(); @@ -84,6 +87,7 @@ private int CheckName(string parameterName) return index; } + /// override public void Clear() { OnChange(); @@ -99,27 +103,32 @@ override public void Clear() } } + /// override public bool Contains(object value) { return (-1 != IndexOf(value)); } + /// override public void CopyTo(Array array, int index) { ((System.Collections.ICollection)InnerList).CopyTo(array, index); } + /// override public System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.ICollection)InnerList).GetEnumerator(); } + /// override protected DbParameter GetParameter(int index) { RangeCheck(index); return InnerList[index]; } + /// override protected DbParameter GetParameter(string parameterName) { int index = IndexOf(parameterName); @@ -158,11 +167,13 @@ private static int IndexOf(System.Collections.IEnumerable items, string paramete return -1; } + /// override public int IndexOf(string parameterName) { return IndexOf(InnerList, parameterName); } + /// override public int IndexOf(object value) { if (null != value) @@ -187,6 +198,7 @@ override public int IndexOf(object value) return -1; } + /// override public void Insert(int index, object value) { OnChange(); @@ -203,6 +215,7 @@ private void RangeCheck(int index) } } + /// override public void Remove(object value) { OnChange(); @@ -218,6 +231,7 @@ override public void Remove(object value) } } + /// override public void RemoveAt(int index) { OnChange(); @@ -225,6 +239,7 @@ override public void RemoveAt(int index) RemoveIndex(index); } + /// override public void RemoveAt(string parameterName) { OnChange(); @@ -252,6 +267,7 @@ private void Replace(int index, object newValue) item.ResetParent(); } + /// override protected void SetParameter(int index, DbParameter value) { OnChange(); @@ -259,6 +275,7 @@ override protected void SetParameter(int index, DbParameter value) Replace(index, value); } + /// override protected void SetParameter(string parameterName, DbParameter value) { OnChange(); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterHelper.cs index 203db31cb7..7877151538 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterHelper.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameterHelper.cs @@ -39,6 +39,7 @@ private object CoercedValue } } + /// override public ParameterDirection Direction { get @@ -66,6 +67,7 @@ override public ParameterDirection Direction } } + /// override public bool IsNullable { get @@ -78,7 +80,7 @@ override public bool IsNullable } } - + /// public int Offset { get @@ -95,6 +97,7 @@ public int Offset } } + /// override public int Size { get @@ -126,6 +129,7 @@ private bool ShouldSerializeSize() return (0 != _size); } + /// override public string SourceColumn { get @@ -139,6 +143,7 @@ override public string SourceColumn } } + /// public override bool SourceColumnNullMapping { get @@ -167,6 +172,7 @@ internal void ResetParent() _parent = null; } + /// override public string ToString() { return ParameterName; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs index aab8236839..78a61fbe0d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs @@ -16,6 +16,7 @@ public sealed partial class SqlParameterCollection : DbParameterCollection { private List _items; // the collection of parameters + /// override public int Count { get @@ -40,6 +41,7 @@ private List InnerList } } + /// override public bool IsFixedSize { get @@ -48,6 +50,7 @@ override public bool IsFixedSize } } + /// override public bool IsReadOnly { get @@ -56,6 +59,7 @@ override public bool IsReadOnly } } + /// override public bool IsSynchronized { get @@ -64,6 +68,7 @@ override public bool IsSynchronized } } + /// override public object SyncRoot { get @@ -72,6 +77,7 @@ override public object SyncRoot } } + /// [ EditorBrowsableAttribute(EditorBrowsableState.Never) ] @@ -84,6 +90,7 @@ override public int Add(object value) return Count - 1; } + /// override public void AddRange(System.Array values) { OnChange(); // fire event before value is validated @@ -112,6 +119,7 @@ private int CheckName(string parameterName) return index; } + /// override public void Clear() { OnChange(); // fire event before value is validated @@ -127,27 +135,32 @@ override public void Clear() } } + /// override public bool Contains(object value) { return (-1 != IndexOf(value)); } + /// override public void CopyTo(Array array, int index) { ((System.Collections.ICollection)InnerList).CopyTo(array, index); } + /// override public System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.ICollection)InnerList).GetEnumerator(); } + /// override protected DbParameter GetParameter(int index) { RangeCheck(index); return InnerList[index]; } + /// override protected DbParameter GetParameter(string parameterName) { int index = IndexOf(parameterName); @@ -186,11 +199,13 @@ private static int IndexOf(System.Collections.IEnumerable items, string paramete return -1; } + /// override public int IndexOf(string parameterName) { return IndexOf(InnerList, parameterName); } + /// override public int IndexOf(object value) { if (null != value) @@ -215,6 +230,7 @@ override public int IndexOf(object value) return -1; } + /// override public void Insert(int index, object value) { OnChange(); // fire event before value is validated @@ -231,6 +247,7 @@ private void RangeCheck(int index) } } + /// override public void Remove(object value) { OnChange(); // fire event before value is validated @@ -246,6 +263,7 @@ override public void Remove(object value) } } + /// override public void RemoveAt(int index) { OnChange(); // fire event before value is validated @@ -253,6 +271,7 @@ override public void RemoveAt(int index) RemoveIndex(index); } + /// override public void RemoveAt(string parameterName) { OnChange(); // fire event before value is validated @@ -280,6 +299,7 @@ private void Replace(int index, object newValue) item.ResetParent(); } + /// override protected void SetParameter(int index, DbParameter value) { OnChange(); // fire event before value is validated @@ -287,6 +307,7 @@ override protected void SetParameter(int index, DbParameter value) Replace(index, value); } + /// override protected void SetParameter(string parameterName, DbParameter value) { OnChange(); // fire event before value is validated diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterHelper.cs index dba3fd0926..b1d5097882 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterHelper.cs @@ -54,6 +54,7 @@ private object CoercedValue } } + /// [ RefreshProperties(RefreshProperties.All), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -86,6 +87,7 @@ override public ParameterDirection Direction } } + /// override public bool IsNullable { // V1.2.3300, XXXParameter V1.0.3300 get @@ -99,6 +101,7 @@ override public bool IsNullable } #if USEOFFSET + /// [ Browsable(false), EditorBrowsableAttribute(EditorBrowsableState.Advanced), // MDAC 69508 @@ -128,6 +131,7 @@ internal int Offset { } #endif + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.DbParameter_Size), @@ -171,6 +175,7 @@ private bool ShouldSerializeSize() return (0 != _size); } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), ResDescriptionAttribute(StringsHelper.ResourceNames.DbParameter_SourceColumn), @@ -188,6 +193,7 @@ override public string SourceColumn } } + /// public override bool SourceColumnNullMapping { get @@ -200,6 +206,7 @@ public override bool SourceColumnNullMapping } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Update), ResDescriptionAttribute(StringsHelper.ResourceNames.DbParameter_SourceVersion), @@ -267,6 +274,7 @@ internal void ResetParent() _parent = null; } + /// override public string ToString() { // V1.2.3300, XXXParameter V1.0.3300 return ParameterName; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameter.cs index 21350052ce..29b7b41190 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameter.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameter.cs @@ -54,6 +54,7 @@ internal XmlDataFeed(XmlReader source) } } + /// [ System.ComponentModel.TypeConverterAttribute(typeof(Microsoft.Data.SqlClient.SqlParameter.SqlParameterConverter)) ] @@ -130,10 +131,12 @@ internal byte NormalizationRuleVersion } } + /// public SqlParameter() : base() { } + /// [EditorBrowsableAttribute(EditorBrowsableState.Advanced)] // MDAC 69508 public SqlParameter(string parameterName, SqlDbType dbType, int size, @@ -153,6 +156,7 @@ public SqlParameter(string parameterName, this.SourceVersion = sourceVersion; this.Value = value; } + /// public SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, @@ -177,12 +181,14 @@ string xmlSchemaCollectionName this._xmlSchemaCollectionOwningSchema = xmlSchemaCollectionOwningSchema; this._xmlSchemaCollectionName = xmlSchemaCollectionName; } + /// public SqlParameter(string parameterName, SqlDbType dbType) : this() { this.ParameterName = parameterName; this.SqlDbType = dbType; } - + + /// public SqlParameter(string parameterName, object value) : this() { Debug.Assert(!(value is SqlDbType), "use SqlParameter(string, SqlDbType)"); @@ -190,7 +196,8 @@ public SqlParameter(string parameterName, object value) : this() this.ParameterName = parameterName; this.Value = value; } - + + /// public SqlParameter(string parameterName, SqlDbType dbType, int size) : this() { this.ParameterName = parameterName; @@ -198,6 +205,7 @@ public SqlParameter(string parameterName, SqlDbType dbType, int size) : this() this.Size = size; } + /// public SqlParameter(string parameterName, SqlDbType dbType, int size, string sourceColumn) : this() { this.ParameterName = parameterName; @@ -221,6 +229,7 @@ internal SqlCollation Collation } } + /// [ Browsable(false), ] @@ -259,6 +268,7 @@ public SqlCompareOptions CompareInfo } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Xml), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlParameter_XmlSchemaCollectionDatabase), @@ -276,6 +286,7 @@ public string XmlSchemaCollectionDatabase } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Xml), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlParameter_XmlSchemaCollectionOwningSchema), @@ -293,6 +304,7 @@ public string XmlSchemaCollectionOwningSchema } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Xml), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlParameter_XmlSchemaCollectionName), @@ -310,6 +322,7 @@ public string XmlSchemaCollectionName } } + /// [ DefaultValue(false), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -321,6 +334,7 @@ public bool ForceColumnEncryption set; } + override public DbType DbType { get @@ -342,6 +356,7 @@ override public DbType DbType } } + /// public override void ResetDbType() { ResetSqlDbType(); @@ -357,6 +372,7 @@ internal MetaType InternalMetaType set { _internalMetaType = value; } } + /// [ Browsable(false), ] @@ -618,6 +634,7 @@ internal bool ParamaterIsSqlType } } + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlParameter_ParameterName), @@ -661,6 +678,7 @@ internal string ParameterNameFixed } } + /// [DefaultValue((Byte)0)] // MDAC 65862 [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataParameter_Precision)] @@ -708,6 +726,7 @@ private bool ShouldSerializePrecision() return (0 != _precision); } + /// [DefaultValue((Byte)0)] // MDAC 65862 [ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data)] [ResDescriptionAttribute(StringsHelper.ResourceNames.DbDataParameter_Scale)] @@ -751,6 +770,7 @@ private bool ShouldSerializeScale() return (0 != _scale); // V1.0 compat, ignore _hasScale } + /// [ RefreshProperties(RefreshProperties.All), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -790,6 +810,7 @@ private bool ShouldSerializeSqlDbType() return (null != _metaType); } + /// public void ResetSqlDbType() { if (null != _metaType) @@ -799,6 +820,7 @@ public void ResetSqlDbType() } } + /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), @@ -849,6 +871,7 @@ public object SqlValue } } + /// [ Browsable(false), EditorBrowsableAttribute(EditorBrowsableState.Advanced) @@ -866,6 +889,7 @@ public String UdtTypeName } } + /// [ Browsable(false), EditorBrowsableAttribute(EditorBrowsableState.Advanced) @@ -883,6 +907,7 @@ public String TypeName } } + /// [ RefreshProperties(RefreshProperties.All), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -1060,6 +1085,7 @@ internal int GetActualSize() return _actualSize; } + /// object ICloneable.Clone() { return new SqlParameter(this); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs index 1379d45d48..ff4565f070 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameterCollection.cs @@ -9,6 +9,7 @@ namespace Microsoft.Data.SqlClient { + /// [ Editor("Microsoft.VSDesigner.Data.Design.DBParametersEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing), ListBindable(false) @@ -34,6 +35,7 @@ internal bool IsDirty } } + /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) @@ -50,6 +52,7 @@ internal bool IsDirty } } + /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) @@ -66,63 +69,75 @@ internal bool IsDirty } } + /// public SqlParameter Add(SqlParameter value) { Add((object)value); return value; } + /// [EditorBrowsableAttribute(EditorBrowsableState.Never)] [ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false)] // 79027 public SqlParameter Add(string parameterName, object value) { return Add(new SqlParameter(parameterName, value)); } + /// public SqlParameter AddWithValue(string parameterName, object value) { // 79027 return Add(new SqlParameter(parameterName, value)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType) { return Add(new SqlParameter(parameterName, sqlDbType)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size) { return Add(new SqlParameter(parameterName, sqlDbType, size)); } + /// public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size, string sourceColumn) { return Add(new SqlParameter(parameterName, sqlDbType, size, sourceColumn)); } + /// public void AddRange(SqlParameter[] values) { AddRange((Array)values); } + /// override public bool Contains(string value) { // WebData 97349 return (-1 != IndexOf(value)); } + /// public bool Contains(SqlParameter value) { return (-1 != IndexOf(value)); } + /// public void CopyTo(SqlParameter[] array, int index) { CopyTo((Array)array, index); } + /// public int IndexOf(SqlParameter value) { return IndexOf((object)value); } + /// public void Insert(int index, SqlParameter value) { Insert(index, (object)value); @@ -133,6 +148,7 @@ private void OnChange() IsDirty = true; } + /// public void Remove(SqlParameter value) { Remove((object)value); From 9081918a1fcf32f1ce4b479a976f197ff05f3307 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 17 Sep 2019 11:26:01 -0700 Subject: [PATCH 16/19] add more include tags --- .../Microsoft.Data.SqlClient/SqlTransaction.xml | 10 +++++----- .../Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs | 4 ++++ .../Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs | 1 + .../src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs | 3 +++ .../Data/SqlClient/SqlRowUpdatedEventHandler.cs | 1 + .../Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs | 4 ++++ .../Data/SqlClient/SqlRowUpdatingEventHandler.cs | 1 + .../src/Microsoft/Data/SqlClient/SqlTransaction.cs | 9 +++++++++ .../Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs | 5 ++++- .../Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs | 1 + .../src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs | 3 +++ .../Data/SqlClient/SqlRowUpdatedEventHandler.cs | 1 + .../Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs | 5 ++++- .../Data/SqlClient/SqlRowUpdatingEventHandler.cs | 1 + .../src/Microsoft/Data/SqlClient/SqlTransaction.cs | 9 +++++++++ 15 files changed, 51 insertions(+), 7 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml index 0ff2fc8f87..6c82cd245d 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml @@ -53,7 +53,7 @@ -or- The connection is broken. - + Gets the object associated with the transaction, or if the transaction is no longer valid. The object associated with the transaction. @@ -71,15 +71,15 @@ To be added. To be added. - + Releases the resources that are held by the object. To be added. - - + + To be added. To be added. To be added. - + Specifies the for this transaction. The for this transaction. The default is . diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs index 1ae9a9836c..250a6658ef 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs @@ -4,16 +4,19 @@ namespace Microsoft.Data.SqlClient { + /// public class SqlRowsCopiedEventArgs : System.EventArgs { private bool _abort; private long _rowsCopied; + /// public SqlRowsCopiedEventArgs(long rowsCopied) { _rowsCopied = rowsCopied; } + /// public bool Abort { get @@ -26,6 +29,7 @@ public bool Abort } } + /// public long RowsCopied { get diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs index 21e5a8bfa0..e85b14af96 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs @@ -4,6 +4,7 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowsCopiedEventHandler(object sender, SqlRowsCopiedEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs index 85f38213b2..aba93e236a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs @@ -7,13 +7,16 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs { + /// public SqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base(row, command, statementType, tableMapping) { } + /// new public SqlCommand Command { get diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs index a6fdd91b72..699223587e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs @@ -4,5 +4,6 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowUpdatedEventHandler(object sender, SqlRowUpdatedEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs index 8a7bbe2e98..9b8b406d6b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs @@ -7,19 +7,23 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs { + /// public SqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base(row, command, statementType, tableMapping) { } + /// new public SqlCommand Command { get { return (base.Command as SqlCommand); } set { base.Command = value; } } + /// override protected IDbCommand BaseCommand { get { return base.BaseCommand; } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs index 3c2e7af9e6..9788e995b0 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs @@ -4,5 +4,6 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowUpdatingEventHandler(object sender, SqlRowUpdatingEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs index 43662f9cf9..eb32a81df7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -10,6 +10,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlTransaction : DbTransaction { private static readonly DiagnosticListener s_diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); @@ -43,6 +44,7 @@ internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection // PROPERTIES //////////////////////////////////////////////////////////////////////////////////////// + /// new public SqlConnection Connection { get @@ -58,6 +60,7 @@ internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection } } + /// override protected DbConnection DbConnection { get @@ -74,6 +77,7 @@ internal SqlInternalTransaction InternalTransaction } } + /// override public IsolationLevel IsolationLevel { get @@ -119,6 +123,7 @@ internal SqlStatistics Statistics // PUBLIC METHODS //////////////////////////////////////////////////////////////////////////////////////// + /// override public void Commit() { Exception e = null; @@ -157,6 +162,7 @@ override public void Commit() } } + /// protected override void Dispose(bool disposing) { if (disposing) @@ -169,6 +175,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + /// override public void Rollback() { Exception e = null; @@ -214,6 +221,7 @@ override public void Rollback() } } + /// public void Rollback(string transactionName) { Exception e = null; @@ -252,6 +260,7 @@ public void Rollback(string transactionName) } } + /// public void Save(string savePointName) { ZombieCheck(); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs index d4b9f53484..434ba18d3a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventArgs.cs @@ -4,17 +4,19 @@ namespace Microsoft.Data.SqlClient { - + /// public class SqlRowsCopiedEventArgs : System.EventArgs { private bool _abort; private long _rowsCopied; + /// public SqlRowsCopiedEventArgs(long rowsCopied) { _rowsCopied = rowsCopied; } + /// public bool Abort { get @@ -28,6 +30,7 @@ public bool Abort } + /// public long RowsCopied { get diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs index a8a88194ce..bf52260361 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/RowsCopiedEventHandler.cs @@ -4,5 +4,6 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowsCopiedEventHandler(object sender, SqlRowsCopiedEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs index 85f38213b2..aba93e236a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEvent.cs @@ -7,13 +7,16 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs { + /// public SqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base(row, command, statementType, tableMapping) { } + /// new public SqlCommand Command { get diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs index a6fdd91b72..699223587e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatedEventHandler.cs @@ -4,5 +4,6 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowUpdatedEventHandler(object sender, SqlRowUpdatedEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs index d14527ae95..9b8b406d6b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEvent.cs @@ -7,20 +7,23 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs { - + /// public SqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base(row, command, statementType, tableMapping) { } + /// new public SqlCommand Command { get { return (base.Command as SqlCommand); } set { base.Command = value; } } + /// override protected IDbCommand BaseCommand { get { return base.BaseCommand; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs index 3c2e7af9e6..9788e995b0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlRowUpdatingEventHandler.cs @@ -4,5 +4,6 @@ namespace Microsoft.Data.SqlClient { + /// public delegate void SqlRowUpdatingEventHandler(object sender, SqlRowUpdatingEventArgs e); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs index 42052e5943..235ac7651d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -11,6 +11,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed class SqlTransaction : DbTransaction { private static int _objectTypeCount; // Bid counter @@ -46,6 +47,7 @@ internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection // PROPERTIES //////////////////////////////////////////////////////////////////////////////////////// + /// new public SqlConnection Connection { // MDAC 66655 get @@ -61,6 +63,7 @@ internal SqlTransaction(SqlInternalConnection internalConnection, SqlConnection } } + /// override protected DbConnection DbConnection { get @@ -77,6 +80,7 @@ internal SqlInternalTransaction InternalTransaction } } + /// override public IsolationLevel IsolationLevel { get @@ -129,6 +133,7 @@ internal SqlStatistics Statistics // PUBLIC METHODS //////////////////////////////////////////////////////////////////////////////////////// + /// override public void Commit() { SqlConnection.ExecutePermission.Demand(); // MDAC 81476 @@ -192,6 +197,7 @@ override public void Commit() } } + /// protected override void Dispose(bool disposing) { if (disposing) @@ -241,6 +247,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + /// override public void Rollback() { if (IsYukonPartialZombie) @@ -313,6 +320,7 @@ override public void Rollback() } } + /// public void Rollback(string transactionName) { SqlConnection.ExecutePermission.Demand(); // MDAC 81476 @@ -374,6 +382,7 @@ public void Rollback(string transactionName) } } + /// public void Save(string savePointName) { SqlConnection.ExecutePermission.Demand(); // MDAC 81476 From 60547aaad0e4dbcb2062b27de685ee964bd05882 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 17 Sep 2019 11:48:46 -0700 Subject: [PATCH 17/19] change snippet tag location to before using MDS --- doc/samples/DataTableReader_GetValues.cs | 2 ++ doc/samples/SqlConnectionStringBuilder.cs | 2 +- doc/samples/SqlConnectionStringBuilder2.cs | 2 +- doc/samples/SqlConnectionStringBuilder_Password.cs | 2 +- doc/samples/SqlConnection_BeginTransaction.cs | 4 ++-- doc/samples/SqlConnection_BeginTransaction2.cs | 4 ++-- doc/samples/SqlDataAdapter.cs | 4 ++-- doc/samples/SqlDataAdapter_RowUpdated.cs | 6 +++--- doc/samples/SqlDataAdapter_SelectCommand.cs | 6 +++--- doc/samples/SqlDataAdapter_SqlDataAdapter.cs | 4 ++-- doc/samples/SqlDataAdapter_SqlDataAdapter1.cs | 4 ++-- doc/samples/SqlDataAdapter_SqlDataAdapter2.cs | 4 ++-- doc/samples/SqlDataAdapter_SqlDataAdapter3.cs | 4 ++-- doc/samples/SqlDataReader_Close.cs | 4 ++-- doc/samples/SqlDataReader_GetOrdinal.cs | 4 ++-- doc/samples/SqlDataReader_IsDBNull.cs | 2 +- doc/samples/SqlDataReader_Read.cs | 2 +- doc/samples/SqlError_State.cs | 7 +++---- doc/samples/SqlError_ToString.cs | 5 ++--- doc/samples/SqlException_Errors1.cs | 4 ++-- doc/samples/SqlException_Errors2.cs | 2 +- doc/samples/SqlParameter.cs | 8 ++++++++ doc/samples/SqlParameterCollection_Add.cs | 4 ++-- doc/samples/SqlParameterCollection_Add1.cs | 4 ++-- doc/samples/SqlParameterCollection_Add3.cs | 4 ++-- doc/samples/SqlParameterCollection_Add5.cs | 4 ++-- doc/samples/SqlParameterCollection_Add6.cs | 7 ++++--- doc/samples/SqlParameterCollection_AddWithValue.cs | 3 ++- doc/samples/SqlParameterCollection_Count.cs | 4 ++-- doc/samples/SqlParameterCollection_Remove.cs | 8 ++++---- doc/samples/SqlParameter_IsNullable.cs | 7 +++---- doc/samples/SqlParameter_ParameterName.cs | 4 ++-- doc/samples/SqlParameter_Precision.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter1.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter2.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter4.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter5.cs | 4 ++-- doc/samples/SqlParameter_SqlParameter6.cs | 4 ++-- doc/samples/SqlRowUpdatingEventArgs.cs | 6 +++--- doc/samples/TransactionIsolationLevels.cs | 6 +++--- 41 files changed, 92 insertions(+), 83 deletions(-) diff --git a/doc/samples/DataTableReader_GetValues.cs b/doc/samples/DataTableReader_GetValues.cs index 97e3be543c..48f2737b5c 100644 --- a/doc/samples/DataTableReader_GetValues.cs +++ b/doc/samples/DataTableReader_GetValues.cs @@ -8,6 +8,7 @@ static void Main() { } // + // using Microsoft.Data.SqlClient; private static void TestGetValues(DataTableReader reader) { // Given a DataTableReader, use the GetValues @@ -40,6 +41,7 @@ private static void TestGetValues(DataTableReader reader) // // + // using Microsoft.Data.SqlClient; private static void TestGetValues(SqlDataReader reader) { // Given a SqlDataReader, use the GetValues diff --git a/doc/samples/SqlConnectionStringBuilder.cs b/doc/samples/SqlConnectionStringBuilder.cs index 723f87f722..bb19d43b16 100644 --- a/doc/samples/SqlConnectionStringBuilder.cs +++ b/doc/samples/SqlConnectionStringBuilder.cs @@ -1,6 +1,6 @@ using System; -// using System.Data; +// using Microsoft.Data.SqlClient; class Program diff --git a/doc/samples/SqlConnectionStringBuilder2.cs b/doc/samples/SqlConnectionStringBuilder2.cs index 16dae6dcab..f4e71b2e9e 100644 --- a/doc/samples/SqlConnectionStringBuilder2.cs +++ b/doc/samples/SqlConnectionStringBuilder2.cs @@ -1,8 +1,8 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; -// class Program { static void Main() diff --git a/doc/samples/SqlConnectionStringBuilder_Password.cs b/doc/samples/SqlConnectionStringBuilder_Password.cs index 05d97add53..25ef3ac3a6 100644 --- a/doc/samples/SqlConnectionStringBuilder_Password.cs +++ b/doc/samples/SqlConnectionStringBuilder_Password.cs @@ -1,5 +1,5 @@ -// using System; +// using Microsoft.Data.SqlClient; class Program { diff --git a/doc/samples/SqlConnection_BeginTransaction.cs b/doc/samples/SqlConnection_BeginTransaction.cs index 7fc2726c14..9665c33c12 100644 --- a/doc/samples/SqlConnection_BeginTransaction.cs +++ b/doc/samples/SqlConnection_BeginTransaction.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; namespace Transaction1CS @@ -13,7 +14,6 @@ static void Main() ExecuteSqlTransaction(connectionString); Console.ReadLine(); } - // private static void ExecuteSqlTransaction(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -65,6 +65,6 @@ private static void ExecuteSqlTransaction(string connectionString) } } } - // } } +// diff --git a/doc/samples/SqlConnection_BeginTransaction2.cs b/doc/samples/SqlConnection_BeginTransaction2.cs index 7fc2726c14..9665c33c12 100644 --- a/doc/samples/SqlConnection_BeginTransaction2.cs +++ b/doc/samples/SqlConnection_BeginTransaction2.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; namespace Transaction1CS @@ -13,7 +14,6 @@ static void Main() ExecuteSqlTransaction(connectionString); Console.ReadLine(); } - // private static void ExecuteSqlTransaction(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -65,6 +65,6 @@ private static void ExecuteSqlTransaction(string connectionString) } } } - // } } +// diff --git a/doc/samples/SqlDataAdapter.cs b/doc/samples/SqlDataAdapter.cs index a42f0fa73e..aed3c92111 100644 --- a/doc/samples/SqlDataAdapter.cs +++ b/doc/samples/SqlDataAdapter.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // public static SqlDataAdapter CreateCustomerAdapter( SqlConnection connection) { @@ -61,5 +61,5 @@ public static SqlDataAdapter CreateCustomerAdapter( return adapter; } - // } +// diff --git a/doc/samples/SqlDataAdapter_RowUpdated.cs b/doc/samples/SqlDataAdapter_RowUpdated.cs index 410f0239a6..9cc7bf637c 100644 --- a/doc/samples/SqlDataAdapter_RowUpdated.cs +++ b/doc/samples/SqlDataAdapter_RowUpdated.cs @@ -1,7 +1,8 @@ using System; -using System.Xml; using System.Data; +// using Microsoft.Data.SqlClient; +using System.Xml; using System.Data.Common; using System.Windows.Forms; @@ -10,7 +11,6 @@ public class Form1: Form private DataSet DataSet1; private DataGrid dataGrid1; - // // handler for RowUpdating event private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e) { @@ -73,5 +73,5 @@ private static void PrintEventArgs(SqlRowUpdatedEventArgs args) " recordsAffected=" + args.RecordsAffected + " status=" + args.Status + ")"); } - // } +// diff --git a/doc/samples/SqlDataAdapter_SelectCommand.cs b/doc/samples/SqlDataAdapter_SelectCommand.cs index 465eff3b3b..aecd1db331 100644 --- a/doc/samples/SqlDataAdapter_SelectCommand.cs +++ b/doc/samples/SqlDataAdapter_SelectCommand.cs @@ -1,7 +1,8 @@ using System; -using System.Xml; using System.Data; +// using Microsoft.Data.SqlClient; +using System.Xml; using System.Data.Common; using System.Windows.Forms; @@ -10,7 +11,6 @@ public class Form1 : Form protected DataSet DataSet1; protected DataGrid dataGrid1; - // private static DataSet SelectRows(DataSet dataset, string connectionString, string queryString) { @@ -24,5 +24,5 @@ private static DataSet SelectRows(DataSet dataset, return dataset; } } - // } +// diff --git a/doc/samples/SqlDataAdapter_SqlDataAdapter.cs b/doc/samples/SqlDataAdapter_SqlDataAdapter.cs index 31ddb3395b..beb2486cbd 100644 --- a/doc/samples/SqlDataAdapter_SqlDataAdapter.cs +++ b/doc/samples/SqlDataAdapter_SqlDataAdapter.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // public static SqlDataAdapter CreateSqlDataAdapter(SqlConnection connection) { SqlDataAdapter adapter = new SqlDataAdapter(); @@ -45,5 +45,5 @@ public static SqlDataAdapter CreateSqlDataAdapter(SqlConnection connection) return adapter; } - // } +// diff --git a/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs b/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs index 642e175982..f181c5ffc2 100644 --- a/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs +++ b/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // public static SqlDataAdapter CreateSqlDataAdapter(SqlCommand selectCommand, SqlConnection connection) { @@ -44,5 +44,5 @@ public static SqlDataAdapter CreateSqlDataAdapter(SqlCommand selectCommand, return adapter; } - // } +// diff --git a/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs b/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs index 7d26150962..275dd4c02a 100644 --- a/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs +++ b/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // public static SqlDataAdapter CreateSqlDataAdapter(string commandText, string connectionString) { @@ -46,5 +46,5 @@ public static SqlDataAdapter CreateSqlDataAdapter(string commandText, return adapter; } - // } +// diff --git a/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs b/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs index 56c135afcd..721e9ef75b 100644 --- a/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs +++ b/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // public static SqlDataAdapter CreateSqlDataAdapter(string commandText, SqlConnection connection) { @@ -45,5 +45,5 @@ public static SqlDataAdapter CreateSqlDataAdapter(string commandText, return adapter; } - // } +// diff --git a/doc/samples/SqlDataReader_Close.cs b/doc/samples/SqlDataReader_Close.cs index fc8fd84fe5..102fa6de85 100644 --- a/doc/samples/SqlDataReader_Close.cs +++ b/doc/samples/SqlDataReader_Close.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -10,7 +11,6 @@ static void Main() + "Integrated Security=SSPI"; ReadOrderData(str); } - // private static void ReadOrderData(string connectionString) { string queryString = @@ -39,5 +39,5 @@ private static void ReadOrderData(string connectionString) } } } - // } +// diff --git a/doc/samples/SqlDataReader_GetOrdinal.cs b/doc/samples/SqlDataReader_GetOrdinal.cs index 6727fbe106..ff69173616 100644 --- a/doc/samples/SqlDataReader_GetOrdinal.cs +++ b/doc/samples/SqlDataReader_GetOrdinal.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -11,7 +12,6 @@ static void Main() ReadGetOrdinal(str); } - // private static void ReadGetOrdinal(string connectionString) { string queryString = "SELECT DISTINCT CustomerID FROM dbo.Orders;"; @@ -37,5 +37,5 @@ private static void ReadGetOrdinal(string connectionString) reader.Close(); } } - // } +// diff --git a/doc/samples/SqlDataReader_IsDBNull.cs b/doc/samples/SqlDataReader_IsDBNull.cs index 3b8a2de4f5..903ac8f424 100644 --- a/doc/samples/SqlDataReader_IsDBNull.cs +++ b/doc/samples/SqlDataReader_IsDBNull.cs @@ -1,6 +1,6 @@ -// using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program diff --git a/doc/samples/SqlDataReader_Read.cs b/doc/samples/SqlDataReader_Read.cs index 5d921e2cc7..3a61b61cfd 100644 --- a/doc/samples/SqlDataReader_Read.cs +++ b/doc/samples/SqlDataReader_Read.cs @@ -1,6 +1,6 @@ -// using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program diff --git a/doc/samples/SqlError_State.cs b/doc/samples/SqlError_State.cs index c3e2e29854..f4f10738af 100644 --- a/doc/samples/SqlError_State.cs +++ b/doc/samples/SqlError_State.cs @@ -1,8 +1,8 @@ using System; -using System; +// +using Microsoft.Data.SqlClient; using System.Collections.Generic; using System.Text; -using Microsoft.Data.SqlClient; namespace Classic_WebData_SqlError.StateCS { @@ -13,7 +13,6 @@ static void Main() //DisplaySqlErrors(); } - // public void DisplaySqlErrors(SqlException exception) { for (int i = 0; i < exception.Errors.Count; i++) @@ -30,6 +29,6 @@ public void DisplaySqlErrors(SqlException exception) } Console.ReadLine(); } - // } } +// diff --git a/doc/samples/SqlError_ToString.cs b/doc/samples/SqlError_ToString.cs index 52c43547fd..b6645049a2 100644 --- a/doc/samples/SqlError_ToString.cs +++ b/doc/samples/SqlError_ToString.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; using System.Text; @@ -11,7 +12,6 @@ static void Main() ShowSqlException(s); Console.ReadLine(); } - // public static void ShowSqlException(string connectionString) { string queryString = "EXECUTE NonExistantStoredProcedure"; @@ -40,8 +40,6 @@ private static void DisplaySqlErrors(SqlException exception) } Console.ReadLine(); } - // - static private string GetConnectionString() { @@ -51,3 +49,4 @@ static private string GetConnectionString() + "Integrated Security=SSPI"; } } +// diff --git a/doc/samples/SqlException_Errors1.cs b/doc/samples/SqlException_Errors1.cs index 51fb42175f..30c54b08f2 100644 --- a/doc/samples/SqlException_Errors1.cs +++ b/doc/samples/SqlException_Errors1.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; using System.Text; @@ -11,7 +12,6 @@ static void Main() ShowSqlException(s); Console.ReadLine(); } - // public static void ShowSqlException(string connectionString) { string queryString = "EXECUTE NonExistantStoredProcedure"; @@ -39,7 +39,6 @@ public static void ShowSqlException(string connectionString) } } } - // static private string GetConnectionString() { @@ -49,3 +48,4 @@ static private string GetConnectionString() + "Integrated Security=SSPI"; } } +// diff --git a/doc/samples/SqlException_Errors2.cs b/doc/samples/SqlException_Errors2.cs index 3df7417197..3f8b3e3e4c 100644 --- a/doc/samples/SqlException_Errors2.cs +++ b/doc/samples/SqlException_Errors2.cs @@ -1,6 +1,6 @@ -// using System; using System.Data; +// using Microsoft.Data.SqlClient; using System.Text; diff --git a/doc/samples/SqlParameter.cs b/doc/samples/SqlParameter.cs index db9b72853d..443bc9fb2e 100644 --- a/doc/samples/SqlParameter.cs +++ b/doc/samples/SqlParameter.cs @@ -9,6 +9,7 @@ static void Main() } // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterOutput() { SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88); @@ -17,6 +18,7 @@ static void CreateSqlParameterOutput() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterNullable() { SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88); @@ -26,6 +28,7 @@ static void CreateSqlParameterNullable() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterOffset() { SqlParameter parameter = new SqlParameter("pDName", SqlDbType.VarChar); @@ -35,6 +38,7 @@ static void CreateSqlParameterOffset() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterPrecisionScale() { SqlParameter parameter = new SqlParameter("Price", SqlDbType.Decimal); @@ -45,6 +49,7 @@ static void CreateSqlParameterPrecisionScale() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterSize() { string description = "12 foot scarf - multiple colors, one previous owner"; @@ -56,6 +61,7 @@ static void CreateSqlParameterSize() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterSourceColumn() { SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88); @@ -64,6 +70,7 @@ static void CreateSqlParameterSourceColumn() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterSourceVersion() { SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88); @@ -73,6 +80,7 @@ static void CreateSqlParameterSourceVersion() // // + // using Microsoft.Data.SqlClient; static void CreateSqlParameterVersion() { SqlParameter parameter = new SqlParameter("Description", SqlDbType.VarChar, 88); diff --git a/doc/samples/SqlParameterCollection_Add.cs b/doc/samples/SqlParameterCollection_Add.cs index 4992a97970..cb03a57e27 100644 --- a/doc/samples/SqlParameterCollection_Add.cs +++ b/doc/samples/SqlParameterCollection_Add.cs @@ -1,13 +1,13 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; public class Sample { - // public void AddSqlParameter(SqlCommand command) { command.Parameters.Add(new SqlParameter("Description", "Beverages")); } - // } +// diff --git a/doc/samples/SqlParameterCollection_Add1.cs b/doc/samples/SqlParameterCollection_Add1.cs index 6679eb47d6..6af67ef415 100644 --- a/doc/samples/SqlParameterCollection_Add1.cs +++ b/doc/samples/SqlParameterCollection_Add1.cs @@ -1,10 +1,10 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; public class Sample { - // public void AddSqlParameter(SqlCommand command) { SqlParameter param = new SqlParameter( @@ -12,5 +12,5 @@ public void AddSqlParameter(SqlCommand command) param.Value = "Beverages"; command.Parameters.Add(param); } - // } +// diff --git a/doc/samples/SqlParameterCollection_Add3.cs b/doc/samples/SqlParameterCollection_Add3.cs index 35bd67d060..9feff70a03 100644 --- a/doc/samples/SqlParameterCollection_Add3.cs +++ b/doc/samples/SqlParameterCollection_Add3.cs @@ -1,10 +1,10 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; public class Sample { - // public void AddSqlParameter(SqlCommand command) { SqlParameter param = command.Parameters.Add( @@ -12,5 +12,5 @@ public void AddSqlParameter(SqlCommand command) param.Size = 16; param.Value = "Beverages"; } - // } +// diff --git a/doc/samples/SqlParameterCollection_Add5.cs b/doc/samples/SqlParameterCollection_Add5.cs index af9e3598e8..661a665f36 100644 --- a/doc/samples/SqlParameterCollection_Add5.cs +++ b/doc/samples/SqlParameterCollection_Add5.cs @@ -1,13 +1,13 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; public class Sample { - // public void AddSqlParameter(SqlCommand cmd) { SqlParameter p1 = cmd.Parameters.Add("@Description", SqlDbType.NVarChar, 16, "Description"); } - // } +// diff --git a/doc/samples/SqlParameterCollection_Add6.cs b/doc/samples/SqlParameterCollection_Add6.cs index 20056f4e64..8ce73cf5dc 100644 --- a/doc/samples/SqlParameterCollection_Add6.cs +++ b/doc/samples/SqlParameterCollection_Add6.cs @@ -1,7 +1,8 @@ using System; -using System.Xml; using System.Data; +// using Microsoft.Data.SqlClient; +using System.Xml; using System.Data.Common; using System.Windows.Forms; @@ -11,7 +12,7 @@ public class Form1 : Form protected DataGrid dataGrid1; protected SqlDataAdapter categoriesAdapter; - // + public void AddSqlParameters() { // ... @@ -25,5 +26,5 @@ public void AddSqlParameters() categoriesAdapter.Fill(categoriesDataSet); } - // } +// diff --git a/doc/samples/SqlParameterCollection_AddWithValue.cs b/doc/samples/SqlParameterCollection_AddWithValue.cs index bf375564ed..abd2d0577c 100644 --- a/doc/samples/SqlParameterCollection_AddWithValue.cs +++ b/doc/samples/SqlParameterCollection_AddWithValue.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -12,7 +13,6 @@ static void Main() UpdateDemographics(id, demo, connectionString); Console.ReadLine(); } - // private static void UpdateDemographics(Int32 customerID, string demoXml, string connectionString) { @@ -52,3 +52,4 @@ static private string GetConnectionString() + "Integrated Security=SSPI"; } } +// diff --git a/doc/samples/SqlParameterCollection_Count.cs b/doc/samples/SqlParameterCollection_Count.cs index f9e58b9392..e9e5224236 100644 --- a/doc/samples/SqlParameterCollection_Count.cs +++ b/doc/samples/SqlParameterCollection_Count.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -11,7 +12,6 @@ static void Main() string summaryString = CreateSqlParameters(7); Console.ReadLine(); } - // static private string CreateSqlParameters(int documentID) { // Assumes GetConnectionString returns a valid connection string to the @@ -63,7 +63,6 @@ static private string CreateSqlParameters(int documentID) } } } - // static private string GetConnectionString() { // To avoid storing the connection string in your code, @@ -73,3 +72,4 @@ static private string GetConnectionString() "Integrated Security=SSPI"; } } +// diff --git a/doc/samples/SqlParameterCollection_Remove.cs b/doc/samples/SqlParameterCollection_Remove.cs index 3fee9801b5..f4fbc7f06d 100644 --- a/doc/samples/SqlParameterCollection_Remove.cs +++ b/doc/samples/SqlParameterCollection_Remove.cs @@ -1,7 +1,8 @@ using System; -using System.Xml; using System.Data; +// using Microsoft.Data.SqlClient; +using System.Xml; using System.Data.Common; using System.Windows.Forms; @@ -12,7 +13,6 @@ public class Form1 : Form protected SqlCommand command; protected SqlParameter param; - // public void SearchSqlParams() { // ... @@ -21,5 +21,5 @@ public void SearchSqlParams() if (command.Parameters.Contains(param)) command.Parameters.Remove(param); } - // -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlParameter_IsNullable.cs b/doc/samples/SqlParameter_IsNullable.cs index adefdf3552..63f0e30401 100644 --- a/doc/samples/SqlParameter_IsNullable.cs +++ b/doc/samples/SqlParameter_IsNullable.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command, string paramValue) { @@ -29,6 +29,5 @@ private static void SetParameterToNull(IDataParameter parameter) throw new ArgumentException("Parameter provided is not nullable", "parameter"); } } - - // -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlParameter_ParameterName.cs b/doc/samples/SqlParameter_ParameterName.cs index d3c0229169..0796eb1c03 100644 --- a/doc/samples/SqlParameter_ParameterName.cs +++ b/doc/samples/SqlParameter_ParameterName.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter(); @@ -18,5 +18,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_Precision.cs b/doc/samples/SqlParameter_Precision.cs index eee3758835..b207fbd1b4 100644 --- a/doc/samples/SqlParameter_Precision.cs +++ b/doc/samples/SqlParameter_Precision.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter("@Price", SqlDbType.Decimal); @@ -17,5 +17,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter.cs b/doc/samples/SqlParameter_SqlParameter.cs index 49855d4be4..ed2b909323 100644 --- a/doc/samples/SqlParameter_SqlParameter.cs +++ b/doc/samples/SqlParameter_SqlParameter.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter(); @@ -19,5 +19,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter1.cs b/doc/samples/SqlParameter_SqlParameter1.cs index 4e1162b27f..7d3567364d 100644 --- a/doc/samples/SqlParameter_SqlParameter1.cs +++ b/doc/samples/SqlParameter_SqlParameter1.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter("@Description", @@ -18,5 +18,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter2.cs b/doc/samples/SqlParameter_SqlParameter2.cs index 2f05e8ee54..0519e133ba 100644 --- a/doc/samples/SqlParameter_SqlParameter2.cs +++ b/doc/samples/SqlParameter_SqlParameter2.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command, string paramValue) { SqlParameter parameter = new SqlParameter("@Description", SqlDbType.VarChar); @@ -18,5 +18,5 @@ private static void AddSqlParameter(SqlCommand command, string paramValue) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter4.cs b/doc/samples/SqlParameter_SqlParameter4.cs index 1a4e9a7a91..03ec49f015 100644 --- a/doc/samples/SqlParameter_SqlParameter4.cs +++ b/doc/samples/SqlParameter_SqlParameter4.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command, string paramValue) { @@ -19,5 +19,5 @@ private static void AddSqlParameter(SqlCommand command, command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter5.cs b/doc/samples/SqlParameter_SqlParameter5.cs index 024f26aade..153ff32d19 100644 --- a/doc/samples/SqlParameter_SqlParameter5.cs +++ b/doc/samples/SqlParameter_SqlParameter5.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter("@Description", @@ -17,5 +17,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlParameter_SqlParameter6.cs b/doc/samples/SqlParameter_SqlParameter6.cs index 4af30b8665..cb6da89383 100644 --- a/doc/samples/SqlParameter_SqlParameter6.cs +++ b/doc/samples/SqlParameter_SqlParameter6.cs @@ -1,5 +1,6 @@ using System; using System.Data; +// using Microsoft.Data.SqlClient; class Program @@ -7,7 +8,6 @@ class Program static void Main() { } - // private static void AddSqlParameter(SqlCommand command) { SqlParameter parameter = new SqlParameter("@Description", @@ -17,5 +17,5 @@ private static void AddSqlParameter(SqlCommand command) command.Parameters.Add(parameter); } - // } +// diff --git a/doc/samples/SqlRowUpdatingEventArgs.cs b/doc/samples/SqlRowUpdatingEventArgs.cs index 021b55dcc3..554adccc0a 100644 --- a/doc/samples/SqlRowUpdatingEventArgs.cs +++ b/doc/samples/SqlRowUpdatingEventArgs.cs @@ -1,7 +1,8 @@ using System; -using System.Xml; using System.Data; +// using Microsoft.Data.SqlClient; +using System.Xml; using System.Data.Common; using System.Windows.Forms; @@ -11,7 +12,6 @@ public class Form1 : Form private DataGrid dataGrid1; - // // handler for RowUpdating event private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e) { @@ -71,5 +71,5 @@ private static void PrintEventArgs(SqlRowUpdatedEventArgs args) " recordsAffected=" + args.RecordsAffected + " status=" + args.Status + ")"); } - // } +// diff --git a/doc/samples/TransactionIsolationLevels.cs b/doc/samples/TransactionIsolationLevels.cs index 09e37eb6a8..4cca4ab684 100644 --- a/doc/samples/TransactionIsolationLevels.cs +++ b/doc/samples/TransactionIsolationLevels.cs @@ -1,7 +1,7 @@ -// -using System; -using Microsoft.Data.SqlClient; +using System; using System.Data; +// +using Microsoft.Data.SqlClient; using System.Threading.Tasks; namespace Microsoft.Data.SqlClient.Samples From 0990c889b169e0fb9e44aae366f48a81b9dfcddc Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 17 Sep 2019 16:07:36 -0700 Subject: [PATCH 18/19] add SqlConnection documentation --- doc/samples/SqlCommand_ExecuteNonQuery.cs | 31 + .../SqlConnection_BeginTransaction1.cs | 65 + .../SqlConnection_BeginTransaction3.cs | 70 + doc/samples/SqlConnection_ConnectionString.cs | 39 + .../SqlConnection_ConnectionString1.cs | 111 ++ .../SqlConnection_ConnectionTimeout.cs | 36 + doc/samples/SqlConnection_CreateCommand.cs | 15 + doc/samples/SqlConnection_DataSource.cs | 36 + doc/samples/SqlConnection_Database.cs | 41 + doc/samples/SqlConnection_Open.cs | 36 + doc/samples/SqlConnection_PacketSize.cs | 35 + doc/samples/SqlConnection_ServerVersion.cs | 28 + doc/samples/SqlConnection_SqlConnection.cs | 34 + doc/samples/SqlConnection_SqlConnection1.cs | 38 + doc/samples/SqlConnection_WorkstationId.cs | 36 + .../SqlConnection.xml | 1284 +++++++++++++++++ .../Microsoft/Data/SqlClient/SqlConnection.cs | 67 +- .../Data/SqlClient/SqlConnectionHelper.cs | 6 +- .../Data/ProviderBase/SqlConnectionHelper.cs | 8 +- .../Microsoft/Data/SqlClient/SqlConnection.cs | 55 +- 20 files changed, 2028 insertions(+), 43 deletions(-) create mode 100644 doc/samples/SqlCommand_ExecuteNonQuery.cs create mode 100644 doc/samples/SqlConnection_BeginTransaction1.cs create mode 100644 doc/samples/SqlConnection_BeginTransaction3.cs create mode 100644 doc/samples/SqlConnection_ConnectionString.cs create mode 100644 doc/samples/SqlConnection_ConnectionString1.cs create mode 100644 doc/samples/SqlConnection_ConnectionTimeout.cs create mode 100644 doc/samples/SqlConnection_CreateCommand.cs create mode 100644 doc/samples/SqlConnection_DataSource.cs create mode 100644 doc/samples/SqlConnection_Database.cs create mode 100644 doc/samples/SqlConnection_Open.cs create mode 100644 doc/samples/SqlConnection_PacketSize.cs create mode 100644 doc/samples/SqlConnection_ServerVersion.cs create mode 100644 doc/samples/SqlConnection_SqlConnection.cs create mode 100644 doc/samples/SqlConnection_SqlConnection1.cs create mode 100644 doc/samples/SqlConnection_WorkstationId.cs create mode 100644 doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml diff --git a/doc/samples/SqlCommand_ExecuteNonQuery.cs b/doc/samples/SqlCommand_ExecuteNonQuery.cs new file mode 100644 index 0000000000..5b90d9c14d --- /dev/null +++ b/doc/samples/SqlCommand_ExecuteNonQuery.cs @@ -0,0 +1,31 @@ +using System; +using System.Data; +using System.Data.SqlClient; + + +namespace SqlCommandCS +{ + class Program + { + static void Main() + { + string str = "Data Source=(local);Initial Catalog=Northwind;" + + "Integrated Security=SSPI"; + string qs = "SELECT OrderID, CustomerID FROM dbo.Orders;"; + CreateCommand(qs, str); + } + // + private static void CreateCommand(string queryString, + string connectionString) + { + using (SqlConnection connection = new SqlConnection( + connectionString)) + { + SqlCommand command = new SqlCommand(queryString, connection); + command.Connection.Open(); + command.ExecuteNonQuery(); + } + } + // + } +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_BeginTransaction1.cs b/doc/samples/SqlConnection_BeginTransaction1.cs new file mode 100644 index 0000000000..5e8be105ca --- /dev/null +++ b/doc/samples/SqlConnection_BeginTransaction1.cs @@ -0,0 +1,65 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + string connectionString = + "Persist Security Info=False;Integrated Security=SSPI;database=Northwind;server=(local)"; + ExecuteSqlTransaction(connectionString); + Console.ReadLine(); + } + // + private static void ExecuteSqlTransaction(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + + SqlCommand command = connection.CreateCommand(); + SqlTransaction transaction; + + // Start a local transaction. + transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted); + + // Must assign both transaction object and connection + // to Command object for a pending local transaction + command.Connection = connection; + command.Transaction = transaction; + + try + { + command.CommandText = + "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; + command.ExecuteNonQuery(); + command.CommandText = + "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; + command.ExecuteNonQuery(); + transaction.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch (Exception e) + { + try + { + transaction.Rollback(); + } + catch (SqlException ex) + { + if (transaction.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + } + } + // +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_BeginTransaction3.cs b/doc/samples/SqlConnection_BeginTransaction3.cs new file mode 100644 index 0000000000..3398405f13 --- /dev/null +++ b/doc/samples/SqlConnection_BeginTransaction3.cs @@ -0,0 +1,70 @@ +using System; +using System.Data; +using System.Data.SqlClient; + + +namespace Transaction1CS +{ + class Program + { + static void Main() + { + string connectionString = + "Persist Security Info=False;Integrated Security=SSPI;database=Northwind;server=(local)"; + ExecuteSqlTransaction(connectionString); + Console.ReadLine(); + } + // + private static void ExecuteSqlTransaction(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + + SqlCommand command = connection.CreateCommand(); + SqlTransaction transaction; + + // Start a local transaction. + transaction = connection.BeginTransaction( + IsolationLevel.ReadCommitted, "SampleTransaction"); + + // Must assign both transaction object and connection + // to Command object for a pending local transaction. + command.Connection = connection; + command.Transaction = transaction; + + try + { + command.CommandText = + "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; + command.ExecuteNonQuery(); + command.CommandText = + "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; + command.ExecuteNonQuery(); + transaction.Commit(); + Console.WriteLine("Both records are written to database."); + } + catch (Exception e) + { + try + { + transaction.Rollback(); + } + catch (SqlException ex) + { + if (transaction.Connection != null) + { + Console.WriteLine("An exception of type " + ex.GetType() + + " was encountered while attempting to roll back the transaction."); + } + } + + Console.WriteLine("An exception of type " + e.GetType() + + " was encountered while inserting the data."); + Console.WriteLine("Neither record was written to database."); + } + } + } + // + } +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_ConnectionString.cs b/doc/samples/SqlConnection_ConnectionString.cs new file mode 100644 index 0000000000..f7c6e10f9e --- /dev/null +++ b/doc/samples/SqlConnection_ConnectionString.cs @@ -0,0 +1,39 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + OpenSqlConnection(); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection() + { + string connectionString = GetConnectionString(); + + using (SqlConnection connection = new SqlConnection()) + { + connection.ConnectionString = connectionString; + + connection.Open(); + + Console.WriteLine("State: {0}", connection.State); + Console.WriteLine("ConnectionString: {0}", + connection.ConnectionString); + } + } + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file. + return "Data Source=MSSQL1;Initial Catalog=AdventureWorks;" + + "Integrated Security=true;"; + } + // + +} diff --git a/doc/samples/SqlConnection_ConnectionString1.cs b/doc/samples/SqlConnection_ConnectionString1.cs new file mode 100644 index 0000000000..8aaedcfe06 --- /dev/null +++ b/doc/samples/SqlConnection_ConnectionString1.cs @@ -0,0 +1,111 @@ +// +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/doc/samples/SqlConnection_ConnectionTimeout.cs b/doc/samples/SqlConnection_ConnectionTimeout.cs new file mode 100644 index 0000000000..410a27c46b --- /dev/null +++ b/doc/samples/SqlConnection_ConnectionTimeout.cs @@ -0,0 +1,36 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + OpenSqlConnection(); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection() + { + string connectionString = GetConnectionString(); + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("State: {0}", connection.State); + Console.WriteLine("ConnectionTimeout: {0}", + connection.ConnectionTimeout); + } + } + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;Connection Timeout=30"; + } + // + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_CreateCommand.cs b/doc/samples/SqlConnection_CreateCommand.cs new file mode 100644 index 0000000000..e2ce0147ad --- /dev/null +++ b/doc/samples/SqlConnection_CreateCommand.cs @@ -0,0 +1,15 @@ +// +using System.Data; +using System.Data.SqlClient; +public class A { + public static void Main() { + using (SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;")) { + connection.Open(); + SqlCommand command= connection.CreateCommand(); + command.CommandText = "SELECT * FROM Categories ORDER BY CategoryID"; + command.CommandTimeout = 15; + command.CommandType = CommandType.Text; + } + } +} +// \ No newline at end of file diff --git a/doc/samples/SqlConnection_DataSource.cs b/doc/samples/SqlConnection_DataSource.cs new file mode 100644 index 0000000000..6230d62bf7 --- /dev/null +++ b/doc/samples/SqlConnection_DataSource.cs @@ -0,0 +1,36 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program1 +{ + static void Mainx() + { + string s = GetConnectionString(); + + OpenSqlConnection(s); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("DataSource: {0}", connection.DataSource); + } + } + // + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_Database.cs b/doc/samples/SqlConnection_Database.cs new file mode 100644 index 0000000000..46ba57fac8 --- /dev/null +++ b/doc/samples/SqlConnection_Database.cs @@ -0,0 +1,41 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program1 +{ + static void Main() + { + string s = GetConnectionString(); + + ChangeSqlDatabase(s); + Console.ReadLine(); + } + + // + private static void ChangeSqlDatabase(string connectionString) + { + // Assumes connectionString represents a valid connection string + // to the AdventureWorks sample database. + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("Database: {0}", connection.Database); + + connection.ChangeDatabase("Northwind"); + Console.WriteLine("Database: {0}", connection.Database); + } + } + // + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_Open.cs b/doc/samples/SqlConnection_Open.cs new file mode 100644 index 0000000000..d2aca4d9b8 --- /dev/null +++ b/doc/samples/SqlConnection_Open.cs @@ -0,0 +1,36 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program1 +{ + static void Main() + { + string s = GetConnectionString(); + + OpenSqlConnection(s); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("State: {0}", connection.State); + } + } + // + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_PacketSize.cs b/doc/samples/SqlConnection_PacketSize.cs new file mode 100644 index 0000000000..6311ece08e --- /dev/null +++ b/doc/samples/SqlConnection_PacketSize.cs @@ -0,0 +1,35 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + OpenSqlConnection(); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection() + { + string connectionString = GetConnectionString(); + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("PacketSize: {0}", connection.PacketSize); + } + } + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;Packet Size=512"; + } + // + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_ServerVersion.cs b/doc/samples/SqlConnection_ServerVersion.cs new file mode 100644 index 0000000000..1cf19c961f --- /dev/null +++ b/doc/samples/SqlConnection_ServerVersion.cs @@ -0,0 +1,28 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +namespace SqlConnection1CS +{ + class Program + { + static void Main() + { + string connectionString = + "Persist Security Info=False;Integrated Security=SSPI;database=Northwind;server=(local)"; + CreateSqlConnection(connectionString); + Console.ReadLine(); + } + // + private static void CreateSqlConnection(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("State: {0}", connection.State ); + } + } + // + } +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_SqlConnection.cs b/doc/samples/SqlConnection_SqlConnection.cs new file mode 100644 index 0000000000..8c053a3661 --- /dev/null +++ b/doc/samples/SqlConnection_SqlConnection.cs @@ -0,0 +1,34 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + OpenSqlConnection(); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection() + { + string connectionString = GetConnectionString(); + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("State: {0}", connection.State); + } + } + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationManager.ConnectionStrings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + // +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_SqlConnection1.cs b/doc/samples/SqlConnection_SqlConnection1.cs new file mode 100644 index 0000000000..c1803a6454 --- /dev/null +++ b/doc/samples/SqlConnection_SqlConnection1.cs @@ -0,0 +1,38 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + OpenSqlConnection(); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection() + { + string connectionString = GetConnectionString(); + + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + + Console.WriteLine("State: {0}", connection.State); + Console.WriteLine("ConnectionString: {0}", + connection.ConnectionString); + } + } + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + // + +} \ No newline at end of file diff --git a/doc/samples/SqlConnection_WorkstationId.cs b/doc/samples/SqlConnection_WorkstationId.cs new file mode 100644 index 0000000000..b5267ffb31 --- /dev/null +++ b/doc/samples/SqlConnection_WorkstationId.cs @@ -0,0 +1,36 @@ +using System; +using System.Data; +using System.Data.SqlClient; + +class Program +{ + static void Main() + { + string s = GetConnectionString(); + + OpenSqlConnection(s); + Console.ReadLine(); + } + + // + private static void OpenSqlConnection(string connectionString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); + Console.WriteLine("WorkstationId: {0}", connection.WorkstationId); + } + } + // + + static private string GetConnectionString() + { + // To avoid storing the connection string in your code, + // you can retrieve it from a configuration file, using the + // System.Configuration.ConfigurationSettings.AppSettings property + return "Data Source=(local);Initial Catalog=AdventureWorks;" + + "Integrated Security=SSPI;"; + } + +} \ No newline at end of file diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml new file mode 100644 index 0000000000..a5283680da --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml @@ -0,0 +1,1284 @@ + + + + + Represents a connection to a SQL Server database. This class cannot be inherited. + + object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. is used together with and to increase performance when connecting to a Microsoft SQL Server database. For all third-party SQL Server products and other OLE DB-supported data sources, use . + + When you create an instance of , all properties are set to their initial values. For a list of these values, see the constructor. + + See for a list of the keywords in a connection string. + + If the goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling `Close` or `Dispose`. `Close` and `Dispose` are functionally equivalent. If the connection pooling value `Pooling` is set to `true` or `yes`, the underlying connection is returned back to the connection pool. On the other hand, if `Pooling` is set to `false` or `no`, the underlying connection to the server is actually closed. + +> [!NOTE] +> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](~/docs/framework/data/adonet/sql-server-connection-pooling.md). + + To ensure that connections are always closed, open the connection inside of a `using` block, as shown in the following code fragment. Doing so ensures that the connection is automatically closed when the code exits the block. + +```vb +Using connection As New SqlConnection(connectionString) + connection.Open() + ' Do work here; connection closed on following line. +End Using + +``` + +```csharp +using (SqlConnection connection = new SqlConnection(connectionString)) + { + connection.Open(); + // Do work here; connection closed on following line. + } +``` + +> [!NOTE] +> To deploy high-performance applications, you must use connection pooling. When you use the .NET Framework Data Provider for SQL Server, you do not have to enable connection pooling because the provider manages this automatically, although you can modify some settings. For more information, see [SQL Server Connection Pooling (ADO.NET)](~/docs/framework/data/adonet/sql-server-connection-pooling.md). + + If a is generated by the method executing a , the remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the . However, the user can reopen the connection and continue. + + An application that creates an instance of the object can require all direct and indirect callers to have sufficient permission to the code by setting declarative or imperative security demands. makes security demands using the object. Users can verify that their code has sufficient permissions by using the object. Users and administrators can also use the [Caspol.exe (Code Access Security Policy Tool)](~/docs/framework/tools/caspol-exe-code-access-security-policy-tool.md) to modify security policy at the machine, user, and enterprise levels. For more information, see [Security in .NET](~/docs/standard/security/index.md). For an example demonstrating how to use security demands, see [Code Access Security and ADO.NET](~/docs/framework/data/adonet/code-access-security.md). + + For more information about handling warning and informational messages from the server, see [Connection Events](~/docs/framework/data/adonet/connection-events.md). For more information about SQL Server engine errors and error messages, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + +> [!CAUTION] +> You can force TCP instead of shared memory. You can do that by prefixing tcp: to the server name in the connection string or you can use localhost. + + + +## Examples + The following example creates a and a . The is opened and set as the for the . The example then calls . To accomplish this, the is passed a connection string and a query string that is a [!INCLUDE[tsql](~/includes/tsql-md.md)] INSERT statement. The connection is closed automatically when the code exits the using block. + + [!code-csharp[SqlCommand_ExecuteNonQuery Example#1](~/sqlclient/doc/samples/SqlCommand_ExecuteNonQuery.cs#1)] + + ]]> + + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + + is created, the read/write properties are set to the following initial values unless they are specifically set using their associated keywords in the property. + +|Properties|Initial value| +|----------------|-------------------| +||empty string ("")| +||15| +||empty string ("")| +||empty string ("")| + + You can change the value for these properties only by using the property. The class provides functionality for creating and managing the contents of connection strings. + + + +## Examples + The following example creates and opens a . + + [!code-csharp[SqlConnection_SqlConnection Example#1](~/sqlclient/doc/samples/SqlConnection_SqlConnection.cs#1)] + + ]]> + + + + The connection used to open the SQL Server database. + Initializes a new instance of the class when given a string that contains the connection string. + + is created, the read/write properties are set to the following initial values unless they are specifically set using their associated keywords in the property. + +|Properties|Initial value| +|----------------|-------------------| +||`connectionString`| +||15| +||empty string ("")| +||empty string ("")| + + You can change the value for these properties only by using the property. The class provides functionality for creating and managing the contents of connection strings. + + + +## Examples + The following example creates and opens a . + + [!code-csharp[SqlConnection_SqlConnection1 Example#1](~/sqlclient/doc/samples/SqlConnection_SqlConnection1.cs#1)] + + ]]> + + + + A connection string that does not use any of the following connection string keywords: , , or ; or that does not use . + A object. If is null, is functionally equivalent to . + To be added. + Initializes a new instance of the class given a connection string, that does not use and a object that contains the user ID and password. + To be added. + + + Gets or sets the access token for the connection. + The access token for the connection. + To be added. + + + To be added. + To be added. + To be added. + To be added. + + + Starts a database transaction. + + + Starts a database transaction. + An object representing the new transaction. + + or method. To make sure that the .NET Framework Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server. + +> [!NOTE] +> If you do not specify an isolation level, the default isolation level is used. To specify an isolation level with the method, use the overload that takes the `iso` parameter (). The isolation level set for a transaction persists after the transaction is completed and until the connection is closed or disposed. Setting the isolation level to **Snapshot** in a database where the snapshot isolation level is not enabled does not throw an exception. The transaction will complete using the default isolation level. + +> [!CAUTION] +> If a transaction is started and a level 16 or higher error occurs on the server, the transaction will not be rolled back until the method is invoked. No exception is thrown on **ExecuteReader**. + +> [!CAUTION] +> When your query returns a large amount of data and calls `BeginTransaction`, a is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open. + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , a , and methods. + + [!code-csharp[SqlConnection_BeginTransaction Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)] + + ]]> + + Parallel transactions are not allowed when using Multiple Active Result Sets (MARS). + Parallel transactions are not supported. + + + The isolation level under which the transaction should run. + Starts a database transaction with the specified isolation level. + An object representing the new transaction. + + or method. To make sure that the .NET Framework Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server. + +> [!NOTE] +> After a transaction is committed or rolled back, the isolation level of the transaction persists for all subsequent commands that are in autocommit mode (the SQL Server default). This can produce unexpected results, such as an isolation level of REPEATABLE READ persisting and locking other users out of a row. To reset the isolation level to the default (READ COMMITTED), execute the [!INCLUDE[tsql](~/includes/tsql-md.md)] SET TRANSACTION ISOLATION LEVEL READ COMMITTED statement, or call followed immediately by . For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels). + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + +> [!CAUTION] +> When your query returns a large amount of data and calls `BeginTransaction`, a is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open. + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , a , and methods. + + [!code-csharp[SqlConnection_BeginTransaction1 Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction1.cs#1)] + + ]]> + + Parallel transactions are not allowed when using Multiple Active Result Sets (MARS). + Parallel transactions are not supported. + + + The name of the transaction. + Starts a database transaction with the specified transaction name. + An object representing the new transaction. + + and in the `savePoint` parameter of the method. + + You must explicitly commit or roll back the transaction using the or method. To make sure that the [!INCLUDE[dnprdnshort](~/includes/dnprdnshort-md.md)] Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server. + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + +> [!CAUTION] +> When your query returns a large amount of data and calls `BeginTransaction`, a is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open. + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , a , and methods. + + [!code-csharp[SqlConnection_BeginTransaction2 Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction2.cs#1)] + + ]]> + + Parallel transactions are not allowed when using Multiple Active Result Sets (MARS). + Parallel transactions are not supported. + + + The isolation level under which the transaction should run. + The name of the transaction. + Starts a database transaction with the specified isolation level and transaction name. + An object representing the new transaction. + + and in the `savePoint` parameter of the method. + + You must explicitly commit or roll back the transaction using the or method. To make sure that the SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server. + +> [!NOTE] +> After a transaction is committed or rolled back, the isolation level of the transaction persists for all subsequent commands that are in autocommit mode (the SQL Server default). This can produce unexpected results, such as an isolation level of REPEATABLE READ persisting and locking other users out of a row. To reset the isolation level to the default (READ COMMITTED), execute the [!INCLUDE[tsql](~/includes/tsql-md.md)] SET TRANSACTION ISOLATION LEVEL READ COMMITTED statement, or call followed immediately by . For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels). + + For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql). + +> [!CAUTION] +> When your query returns a large amount of data and calls `BeginTransaction`, a is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open. + + + +## Examples + The following example creates a and a . It also demonstrates how to use the , a , and methods. + + [!code-csharp[SqlConnection_BeginTransaction3 Example#1](~/sqlclient/doc/samples/SqlConnection_BeginTransaction3.cs#1)] + + ]]> + + Parallel transactions are not allowed when using Multiple Active Result Sets (MARS). + Parallel transactions are not supported. + + + The name of the database to use instead of the current database. + Changes the current database for an open . + + and displays some of its read-only properties. + + [!code-csharp[SqlConnection_Database Example#1](~/sqlclient/doc/samples/SqlConnection_Database.cs#1)] + + ]]> + + The database name is not valid. + The connection is not open. + Cannot change the database. + + + Changes the SQL Server password. + + + 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. + + method changes the SQL Server password for the user indicated in the supplied `connectionString` parameter to the value supplied in the `newPassword` parameter. If the connection string includes the option for integrated security (that is, "Integrated Security=True" or the equivalent), an exception is thrown. + + To determine that the password has expired, calling the method raises a . In order to indicate that the password that is contained within the connection string must be reset, the property for the exception contains the status value 18487 or 18488. The first value (18487) indicates that the password has expired and the second (18488) indicates that the password must be reset before logging in. + + This method opens its own connection to the server, requests the password change, and closes the connection as soon as it has completed. This connection is not retrieved from, nor returned to, the SQL Server connection pool. + + + +## Examples + The following is a simple example of changing a password: + +```csharp +class Program { + static void Main(string[] args) { + Microsoft.Data.SqlClient.SqlConnection.ChangePassword( + "Data Source=a_server;Initial Catalog=a_database;UID=user;PWD=old_password", + "new_password"); + } +} + +``` + +```vb +Module Module1 + Sub Main() +Microsoft.Data.SqlClient.SqlConnection.ChangePassword( + "Data Source=a_server;Initial Catalog=a_database;UID=user;PWD=old_password", + "new_password") + End Sub +End Module + +``` + + The following console application demonstrates the issues involved in changing a user's password because the current password has expired. + + [!code-csharp[SqlConnection_ConnectionString1#1](~/sqlclient/doc/samples/SqlConnection_ConnectionString1.cs#1)] + + ]]> + + The connection string includes the option to use integrated security. + + Or + + The exceeds 128 characters. + Either the or the parameter is null. + + + The connection string that contains enough information to connect to a server. The connection string should not use any of the following connection string keywords: , , or ; or . + A object. + The new password. must be read only. The password must also comply with any password security policy set on the server (for example, minimum length and requirements for specific characters). + To be added. + Changes the SQL Server password for the user indicated in the object. + To be added. + + The connection string contains any combination of , , or . + +-or- + +The connection string contains . + +-or- + + (or ) is greater than 128 characters. + +-or- + + (or ) is not read only. + +-or- + + (or ) is an empty string. + One of the parameters (, , or ) is null. + + + Empties the connection pool. + + resets (or empties) the connection pool. If there are connections in use at the time of the call, they are marked appropriately and will be discarded (instead of being returned to the pool) when is called on them. + + ]]> + + + + The to be cleared from the pool. + Empties the connection pool associated with the specified connection. + + clears the connection pool that is associated with the `connection`. If additional connections associated with `connection` are in use at the time of the call, they are marked appropriately and are discarded (instead of being returned to the pool) when is called on them. + + ]]> + + + + The connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed. + The connection ID of the most recent connection attempt. + + works regardless of which version of the server you connect to, but extended events logs and entry on connectivity ring buffer errors will not be present in [!INCLUDE[sskatmai_r2](~/includes/sskatmai-r2-md.md)] and earlier. + + You can locate the connection ID in the extended events log to see if the failure was on the server if the extended event for logging connection ID is enabled. You can also locate the connection ID in the connection ring buffer ([Connectivity troubleshooting in SQL Server 2008 with the Connectivity Ring Buffer](https://go.microsoft.com/fwlink/?LinkId=207752)) for certain connection errors. If the connection ID is not in the connection ring buffer, you can assume a network error. + + ]]> + + + + Closes the connection to the database. This is the preferred method of closing any open connection. + + method rolls back any pending transactions. It then releases the connection to the connection pool, or closes the connection if connection pooling is disabled. + +> [!NOTE] +> Pending transactions started using [!INCLUDE[tsql](~/includes/tsql-md.md)] or are automatically rolled back when the connection is reset if connection pooling is enabled. If connection pooling is off, the transaction is rolled back after `SqlConnection.Close` is called. Transactions started through are controlled through the `System.Transactions` infrastructure, and are not affected by `SqlConnection.Close`. + + An application can call more than one time. No exception is generated. + + If the goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling `Close` or `Dispose`. `Close` and `Dispose` are functionally equivalent. If the connection pooling value `Pooling` is set to `true` or `yes`, the underlying connection is returned back to the connection pool. On the other hand, if `Pooling` is set to `false` or `no`, the underlying connection to the server is closed. + +> [!NOTE] +> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](~/docs/framework/data/adonet/sql-server-connection-pooling.md). + +> [!CAUTION] +> Do not call `Close` or `Dispose` on a Connection, a DataReader, or any other managed object in the `Finalize` method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](~/docs/standard/garbage-collection/index.md). + + + +## Examples + The following example creates a , opens it, displays some of its properties. The connection is automatically closed at the end of the `using` block. + + [!code-csharp[SqlConnection_Open Example#1](~/sqlclient/doc/samples/SqlConnection_Open.cs#1)] + + ]]> + + The connection-level error that occurred while opening the connection. + + + Gets or sets the time-to-live for column encryption key entries in the column encryption key cache for the Always Encrypted feature. The default value is 2 hours. 0 means no caching at all. + The time interval. + To be added. + + + Gets or sets a value that indicates whether query metadata caching is enabled (true) or not (false) for parameterized queries running against Always Encrypted enabled databases. The default value is true. + Returns true if query metadata caching is enabled; otherwise false. true is the default. + + + + + + Allows you to set a list of trusted key paths for a database server. If while processing an application query the driver receives a key path that is not on the list, the query will fail. This property provides additional protection against security attacks that involve a compromised SQL Server providing fake key paths, which may lead to leaking key store credentials. + The list of trusted master key paths for the column encryption. + To be added. + + + Gets or sets the string used to open a SQL Server database. + The connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string. + + is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set , minus security information if the Persist Security Info value is set to `false` (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to `true`. + You can use the property to connect to a database. The following example illustrates a typical connection string. + +``` +"Persist Security Info=False;Integrated Security=true;Initial Catalog=Northwind;server=(local)" +``` + + Use the new to construct valid connection strings at run time. For more information, see [Connection String Builders](~/docs/framework/data/adonet/connection-string-builders.md). + + The property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties. When the connection string is set, these properties are updated, except when an error is detected. In this case, none of the properties are updated. properties return only those settings that are contained in the . + + To connect to a local computer, specify "(local)" for the server. If a server name is not specified, a connection will be attempted to the default instance on the local computer. + + Resetting the on a closed connection resets all connection string values (and related properties) including the password. For example, if you set a connection string that includes "Database= AdventureWorks", and then reset the connection string to "Data Source=myserver;Integrated Security=true", the property is no longer set to "AdventureWorks". + + The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception, such as , is generated. Other errors can be found only when an attempt is made to open the connection. + + The basic format of a connection string includes a series of keyword/value pairs separated by semicolons. The equal sign (=) connects each keyword and its value. To include values that contain a semicolon, single-quote character, or double-quote character, the value must be enclosed in double quotation marks. If the value contains both a semicolon and a double-quote character, the value can be enclosed in single quotation marks. The single quotation mark is also useful if the value starts with a double-quote character. Conversely, the double quotation mark can be used if the value starts with a single quotation mark. If the value contains both single-quote and double-quote characters, the quotation mark character used to enclose the value must be doubled every time it occurs within the value. + + To include preceding or trailing spaces in the string value, the value must be enclosed in either single quotation marks or double quotation marks. Any leading or trailing spaces around integer, Boolean, or enumerated values are ignored, even if enclosed in quotation marks. However, spaces within a string literal keyword or value are preserved. Single or double quotation marks may be used within a connection string without using delimiters (for example, Data Source= my'Server or Data Source= my"Server), unless a quotation mark character is the first or last character in the value. + + Keywords are not case sensitive. + + The following table lists the valid names for keyword values within the . + +|Keyword|Default|Description| +|-------------|-------------|-----------------| +|Addr|N/A|Synonym of **Data Source**.| +|Address|N/A|Synonym of **Data Source**.| +|App|N/A|Synonym of **Application Name**.| +|Application Name|N/A|The name of the application, or '.NET SQLClient Data Provider' if no application name is provided.

An application name can be 128 characters or less.| +|`ApplicationIntent`|`ReadWrite`|Declares the application workload type when connecting to a server. Possible values are `ReadOnly` and `ReadWrite`. For example:

`ApplicationIntent=ReadOnly`

For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](~/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md).| +|Asynchronous Processing

-or-

Async|'false'|When `true`, enables asynchronous operation support. Recognized values are `true`, `false`, `yes`, and `no`.

This property is ignored beginning in [!INCLUDE[net_v45](~/includes/net-v45-md.md)]. For more information about SqlClient support for asynchronous programming, see [Asynchronous Programming](~/docs/framework/data/adonet/asynchronous-programming.md).| +|AttachDBFilename

-or-

Extended Properties

-or-

Initial File Name|N/A|The name of the primary database file, including the full path name of an attachable database. AttachDBFilename is only supported for primary data files with an .mdf extension.

If the value of the AttachDBFileName key is specified in the connection string, the database is attached and becomes the default database for the connection.

If this key is not specified and if the database was previously attached, the database will not be reattached. The previously attached database will be used as the default database for the connection.

If this key is specified together with the AttachDBFileName key, the value of this key will be used as the alias. However, if the name is already used in another attached database, the connection will fail.

The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. **Note:** Remote server, HTTP, and UNC path names are not supported.

The database name must be specified with the keyword 'database' (or one of its aliases) as in the following:

"AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated security=true;database=YourDatabase"

An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.| +|Authentication|N/A|The authentication method used for [Connecting to SQL Database By Using Azure Active Directory Authentication](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/#7-connect-to-your-database-by-using-azure-active-directory-identities).

Valid values are:

Active Directory Integrated, Active Directory Password, Sql Password.| +|Column Encryption Setting|N/A|Enables or disables [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2017) functionality for the connection.| +|Connect Timeout

-or-

Connection Timeout

-or-

Timeout|15|The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.

Valid values are greater than or equal to 0 and less than or equal to 2147483647.

When opening a connection to a Azure SQL Database, set the connection timeout to 30 seconds.| +|Connection Lifetime

-or-

Load Balance Timeout|0|When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by `Connection Lifetime`. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.

A value of zero (0) causes pooled connections to have the maximum connection timeout.| +|ConnectRetryCount|1|Controls the number of reconnection attempts after the client identifies an idle connection failure. Valid values are 0 to 255. The default is 1. 0 means do not attempt to reconnect (disable connection resiliency).

For additional information about idle connection resiliency, see [Technical Article - Idle Connection Resiliency](https://go.microsoft.com/fwlink/?LinkId=393996).| +|ConnectRetryInterval|10|Specifies the time between each connection retry attempt (ConnectRetryCount). Valid values are 1 to 60 seconds (default=10), applied after the first reconnection attempt. When a broken connection is detected, the client immediately attempts to reconnect; this is the first reconnection attempt and only occurs if ConnectRetryCount is greater than 0. If the first reconnection attempt fails and ConnectRetryCount is greater than 1, the client waits ConnectRetryInterval to try the second and subsequent reconnection attempts.

For additional information about idle connection resiliency, see [Technical Article - Idle Connection Resiliency](https://go.microsoft.com/fwlink/?LinkId=393996).| +|Context Connection|'false'|`true` if an in-process connection to SQL Server should be made.| +|Current Language

-or-

Language|N/A|Sets the language used for database server warning or error messages.

The language name can be 128 characters or less.| +|Data Source

-or-

Server

-or-

Address

-or-

Addr

-or-

Network Address|N/A|The name or network address of the instance of SQL Server to which to connect. The port number can be specified after the server name:

`server=tcp:servername, portnumber`

When specifying a local instance, always use (local). To force a protocol, add one of the following prefixes:

`np:(local), tcp:(local), lpc:(local)`

Beginning in [!INCLUDE[net_v45](~/includes/net-v45-md.md)], you can also connect to a LocalDB database as follows:

`server=(localdb)\\myInstance`

For more information about LocalDB, see [SqlClient Support for LocalDB](~/docs/framework/data/adonet/sql/sqlclient-support-for-localdb.md).

**Data Source** must use the TCP format or the Named Pipes format.

TCP format is as follows:

- tcp:\\\
- tcp:\,\

The TCP format must start with the prefix "tcp:" and is followed by the database instance, as specified by a host name and an instance name. This format is not applicable when connecting to Azure SQL Database. TCP is automatically selected for connections to Azure SQL Database when no protocol is specified.

The host name MUST be specified in one of the following ways:

- NetBIOSName
- IPv4Address
- IPv6Address

The instance name is used to resolve to a particular TCP/IP port number on which a database instance is hosted. Alternatively, specifying a TCP/IP port number directly is also allowed. If both instance name and port number are not present, the default database instance is used.

The Named Pipes format is as follows:

- np:\\\\\pipe\\

The Named Pipes format MUST start with the prefix "np:" and is followed by a named pipe name.

The host name MUST be specified in one of the following ways:

- NetBIOSName
- IPv4Address
- IPv6Address

The pipe name is used to identify the database instance to which the .NET Framework application will be connected.

If the value of the **Network** key is specified, the prefixes "tcp:" and "np:" should not be specified. **Note:** You can force the use of TCP instead of shared memory, either by prefixing **tcp:** to the server name in the connection string, or by using **localhost**.| +|Encrypt|'false'|When `true`, SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed. Recognized values are `true`, `false`, `yes`, and `no`. For more information, see [Connection String Syntax](~/docs/framework/data/adonet/connection-string-syntax.md).

Beginning in [!INCLUDE[net_v45](~/includes/net-v45-md.md)], when `TrustServerCertificate` is false and `Encrypt` is true, the server name (or IP address) in a SQL Server SSL certificate must exactly match the server name (or IP address) specified in the connection string. Otherwise, the connection attempt will fail. For information about support for certificates whose subject starts with a wildcard character (*), see [Accepted wildcards used by server certificates for server authentication](https://support.microsoft.com/kb/258858).| +|Enlist|'true'|`true` indicates that the SQL Server connection pooler automatically enlists the connection in the creation thread's current transaction context.| +|Failover Partner|N/A|The name of the failover partner server where database mirroring is configured.

If the value of this key is "", then **Initial Catalog** must be present, and its value must not be "".

The server name can be 128 characters or less.

If you specify a failover partner but the failover partner server is not configured for database mirroring and the primary server (specified with the Server keyword) is not available, then the connection will fail.

If you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server (specified with the Server keyword) will succeed if the primary server is available.| +|Initial Catalog

-or-

Database|N/A|The name of the database.

The database name can be 128 characters or less.| +|Integrated Security

-or-

Trusted_Connection|'false'|When `false`, User ID and Password are specified in the connection. When `true`, the current Windows account credentials are used for authentication.

Recognized values are `true`, `false`, `yes`, `no`, and `sspi` (strongly recommended), which is equivalent to `true`.

If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.

is a more secure way to specify credentials for a connection that uses SQL Server Authentication (`Integrated Security=false`).| +|Max Pool Size|100|The maximum number of connections that are allowed in the pool.

Valid values are greater than or equal to 1. Values that are less than **Min Pool Size** generate an error.| +|Min Pool Size|0|The minimum number of connections that are allowed in the pool.

Valid values are greater than or equal to 0. Zero (0) in this field means no minimum connections are initially opened.

Values that are greater than **Max Pool Size** generate an error.| +|MultipleActiveResultSets|'false'|When `true`, an application can maintain multiple active result sets (MARS). When `false`, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection.

Recognized values are `true` and `false`.

For more information, see [Multiple Active Result Sets (MARS)](~/docs/framework/data/adonet/sql/multiple-active-result-sets-mars.md).| +|`MultiSubnetFailover`|FALSE|Always specify `multiSubnetFailover=True` when connecting to the availability group listener of a SQL Server 2012 (or later) availability group or a SQL Server 2012 (or later) Failover Cluster Instance. `multiSubnetFailover=True` configures SqlClient to provide faster detection of and connection to the (currently) active server. Possible values are `Yes` and `No`, `True` and `False` or `1` and `0`. For example:

`MultiSubnetFailover=True`

The default is `False`. For more information about SqlClient's support for Always On AGs, see [SqlClient Support for High Availability, Disaster Recovery](~/docs/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery.md).| +|Network Library

-or-

Network

-or-

Net|N/A|The network library used to establish a connection to an instance of SQL Server. Supported values include:

dbnmpntw (Named Pipes)

dbmsrpcn (Multiprotocol, Windows RPC)

dbmsadsn (Apple Talk)

dbmsgnet (VIA)

dbmslpcn (Shared Memory)

dbmsspxn (IPX/SPX)

dbmssocn (TCP/IP)

Dbmsvinn (Banyan Vines)

The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used. In this example, the network library is Win32 Winsock TCP/IP (dbmssocn), and 1433 is the port being used.

`Network Library=dbmssocn;Data Source=000.000.000.000,1433;`| +|Packet Size|8000|Size in bytes of the network packets used to communicate with an instance of SQL Server.

The packet size can be greater than or equal to 512 and less than or equal to 32768.| +|Password

-or-

PWD|N/A|The password for the SQL Server account logging on. Not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keyword instead. is a more secure way to specify credentials for a connection that uses SQL Server Authentication.

The password must be 128 characters or less.| +|Persist Security Info

-or-

PersistSecurityInfo|'false'|When set to `false` or `no` (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password. Recognized values are `true`, `false`, `yes`, and `no`.| +|PoolBlockingPeriod|Auto|Sets the blocking period behavior for a connection pool. See property for details.| +|Pooling|'true'|When the value of this key is set to true, any newly created connection will be added to the pool when closed by the application. In a next attempt to open the same connection, that connection will be drawn from the pool.

Connections are considered the same if they have the same connection string. Different connections have different connection strings.

The value of this key can be "true", "false", "yes", or "no".| +|Replication|'false'|`true` if replication is supported using the connection.| +|Transaction Binding|Implicit Unbind|Controls connection association with an enlisted `System.Transactions` transaction.

Possible values are:

`Transaction Binding=Implicit Unbind;`

`Transaction Binding=Explicit Unbind;`

Implicit Unbind causes the connection to detach from the transaction when it ends. After detaching, additional requests on the connection are performed in autocommit mode. The `System.Transactions.Transaction.Current` property is not checked when executing requests while the transaction is active. After the transaction has ended, additional requests are performed in autocommit mode.

If the system ends the transaction (in the scope of a using block) before the last command completes, it will throw .

Explicit Unbind causes the connection to remain attached to the transaction until the connection is closed or an explicit `SqlConnection.TransactionEnlist(null)` is called. Beginning in [!INCLUDE[net_v40_long](~/includes/net-v40-long-md.md)], changes to Implicit Unbind make Explicit Unbind obsolete. An `InvalidOperationException` is thrown if `Transaction.Current` is not the enlisted transaction or if the enlisted transaction is not active.| +|TransparentNetworkIPResolution|See description.|When the value of this key is set to `true`, the application is required to retrieve all IP addresses for a particular DNS entry and attempt to connect with the first one in the list. If the connection is not established within 0.5 seconds, the application will try to connect to all others in parallel. When the first answers, the application will establish the connection with the respondent IP address.

If the `MultiSubnetFailover` key is set to `true`, `TransparentNetworkIPResolution` is ignored.

If the `Failover Partner` key is set, `TransparentNetworkIPResolution` is ignored.

The value of this key must be `true`, `false`, `yes`, or `no`.

A value of `yes` is treated the same as a value of `true`.

A value of `no` is treated the same as a value of `false`.

The default values are as follows:

  • `false` when:

    • Connecting to Azure SQL Database where the data source ends with:

      • .database.chinacloudapi.cn
      • .database.usgovcloudapi.net
      • .database.cloudapi.de
      • .database.windows.net
    • `Authentication` is 'Active Directory Password' or 'Active Directory Integrated'
  • `true` in all other cases.
| +|TrustServerCertificate|'false'|When set to `true`, SSL is used to encrypt the channel when bypassing walking the certificate chain to validate trust. If TrustServerCertificate is set to `true` and Encrypt is set to `false`, the channel is not encrypted. Recognized values are `true`, `false`, `yes`, and `no`. For more information, see [Connection String Syntax](~/docs/framework/data/adonet/connection-string-syntax.md).| +|Type System Version|N/A|A string value that indicates the type system the application expects. The functionality available to a client application is dependent on the version of SQL Server and the compatibility level of the database. Explicitly setting the type system version that the client application was written for avoids potential problems that could cause an application to break if a different version of SQL Server is used. **Note:** The type system version cannot be set for common language runtime (CLR) code executing in-process in SQL Server. For more information, see [SQL Server Common Language Runtime Integration](~/docs/framework/data/adonet/sql/sql-server-common-language-runtime-integration.md).

Possible values are:

`Type System Version=SQL Server 2012;`

`Type System Version=SQL Server 2008;`

`Type System Version=SQL Server 2005;`

`Type System Version=Latest;`

`Type System Version=SQL Server 2012;` specifies that the application will require version 11.0.0.0 of Microsoft.SqlServer.Types.dll. The other `Type System Version` settings will require version 10.0.0.0 of Microsoft.SqlServer.Types.dll.

`Latest` is obsolete and should not be used. `Latest` is equivalent to `Type System Version=SQL Server 2008;`.| +|User ID

-or-

UID

-or-|N/A|The SQL Server login account. Not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keywords instead. is a more secure way to specify credentials for a connection that uses SQL Server Authentication.

The user ID must be 128 characters or less.| +|User Instance|'false'|A value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller.| +|Workstation ID

-or-

WSID|The local computer name|The name of the workstation connecting to SQL Server.

The ID must be 128 characters or less.| + + The following list contains the valid names for connection pooling values within the . For more information, see [SQL Server Connection Pooling (ADO.NET)](~/docs/framework/data/adonet/sql-server-connection-pooling.md). + +- Connection Lifetime (or Load Balance Timeout) + +- Enlist + +- Max Pool Size + +- Min Pool Size + +- Pooling + + When you are setting keyword or connection pooling values that require a Boolean value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. Integer values are represented as strings. +> [!NOTE] +> The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. Therefore, it does not support the use of an ODBC data source name (DSN) when connecting to SQL Server because it does not add an ODBC layer. + +> [!NOTE] +> Universal data link (UDL) files are not supported for the .NET Framework Data Provider for SQL Server. + +> [!CAUTION] +> In this release, the application should use caution when constructing a connection string based on user input (for example when retrieving user ID and password information from a dialog box, and appending it to the connection string). The application should make sure that a user cannot embed additional connection string parameters in these values (for example, entering a password as "validpassword;database=somedb" in an attempt to attach to a different database). If you need to construct connection strings based on user input, use the new , which validates the connection string and helps to eliminate this problem. See [Connection String Builders](~/docs/framework/data/adonet/connection-string-builders.md) for more information. + + + +## Examples + The following example creates a and sets the property before opening the connection. + + [!code-csharp[SqlConnection_ConnectionString Example#1](~/sqlclient/doc/samples/SqlConnection_ConnectionString.cs#1)] + + ]]>
+
+ An invalid connection string argument has been supplied, or a required connection string argument has not been supplied. +
+ + Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error. + The time (in seconds) to wait for a connection to open. The default value is 15 seconds. + + because an attempt to connect waits indefinitely. + + + +## Examples + The following example creates a and sets the `Connection Timeout` to 30 seconds in the connection string. The code opens the connection and displays the property in the console window. + + [!code-csharp[SqlConnection_ConnectionTimeout Example#1](~/sqlclient/doc/samples/SqlConnection_ConnectionTimeout.cs#1)] + + ]]> + + The value set is less than 0. + + + Creates and returns a object associated with the . + A object. + + + + + + To be added. + To be added. + To be added. + + + Gets or sets the object for this connection. + The object for this connection. + + object with . + + The default value of is null. + + An exception will be raised: + +- If is set on an open connection. + +- If is set when `Context Connection=true`. + +- If is set when `Integrated Security = true`. + +- If is set when the connection string uses `Password`. + +- If is set when the connection string uses `UserID`. + + ]]> + + + + To be added. + To be added. + To be added. + + + Gets the name of the current database or the database to be used after a connection is opened. + The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string. + + property updates dynamically. If you change the current database using a [!INCLUDE[tsql](~/includes/tsql-md.md)] statement or the method, an informational message is sent and the property is updated automatically. + + + +## Examples + The following example creates a and displays some of its read-only properties. + + [!code-csharp[SqlConnection_Database Example#1](~/sqlclient/doc/samples/SqlConnection_Database.cs#1)] + + ]]> + + + + Gets the name of the instance of SQL Server to which to connect. + The name of the instance of SQL Server to which to connect. The default value is an empty string. + + [!NOTE] +> The property returns `null` if the connection string for the is "context connection=true". + + + +## Examples + The following example creates a and displays some of its read-only properties. + + [!code-csharp[SqlConnection_DataSource Example#1](~/sqlclient/doc/samples/SqlConnection_DataSource.cs#1)] + + ]]> + + + + To be added. + To be added. + To be added. + + + To be added. + To be added. + To be added. + + + A reference to an existing in which to enlist. + Enlists in the specified transaction as a distributed transaction. + + method to enlist in a distributed transaction. Because it enlists a connection in a instance, **EnlistTransaction** takes advantage of functionality available in the namespace for managing distributed transactions, making it preferable to **EnlistDistributedTransaction** for this purpose. For more information, see [Distributed Transactions](~/docs/framework/data/adonet/distributed-transactions.md). + + You can continue to enlist in an existing distributed transaction using the **EnlistDistributedTransaction** method if auto-enlistment is disabled. Enlisting in an existing distributed transaction makes sure that, if the transaction is committed or rolled back, modifications made by the code at the data source are also committed or rolled back. + + `EnlistDistributedTransaction` returns an exception if the has already started a transaction using . However, if the transaction is a local transaction started at the data source (for example, by explicitly executing the BEGIN TRANSACTION statement using an object), **EnlistDistributedTransaction** rolls back the local transaction and enlists in the existing distributed transaction as requested. You do not receive notice that the local transaction was rolled back, and are responsible for managing any local transactions not started using . + + ]]> + + + + A reference to an existing in which to enlist. + Enlists in the specified transaction as a distributed transaction. + + method to enlist in a distributed transaction. Because it enlists a connection in a instance, **EnlistTransaction** takes advantage of functionality available in the namespace for managing distributed transactions, making it preferable to **EnlistDistributedTransaction**, which uses a **System.EnterpriseServices.ITransaction** object. It also has slightly different semantics: once a connection is explicitly enlisted on a transaction, it cannot be unenlisted or enlisted in another transaction until the first transaction finishes. For more information about distributed transactions, see [Distributed Transactions](~/docs/framework/data/adonet/distributed-transactions.md). + + ]]> + + + + Gets or sets the property. + + if the property has been set; otherwise . + + to `true`, errors that were previously treated as exceptions are now handled as events. All events fire immediately and are handled by the event handler. If is is set to `false`, then events are handled at the end of the procedure. + +> [!NOTE] +> An error with a severity level of 17 or above that causes the server to stop processing the command needs to be handled as an exception. In this case, an exception is thrown regardless of how the error is handled in the event. + + For more information on working with events, see [Connection Events](~/docs/framework/data/adonet/connection-events.md). For more information on errors generated by the SQL Server engine, see [Database Engine Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). + + ]]> + + + + Returns schema information for the data source of this . + + + + + + Returns schema information for the data source of this . For more information about scheme, see [SQL Server Schema Collections](~/docs/framework/data/adonet/sql-server-schema-collections.md). + A that contains schema information. + To be added. + + + Specifies the name of the schema to return. + Returns schema information for the data source of this using the specified string for the schema name. + A that contains schema information. + + + + + is specified as null. + + + Specifies the name of the schema to return. + A set of restriction values for the requested schema. + Returns schema information for the data source of this using the specified string for the schema name and the specified string array for the restriction values. + A that contains schema information. + + , see . + + ]]> + + + is specified as null. + + + + Occurs when SQL Server returns a warning or informational message. + + delegate to listen to this event. + + The event occurs when a message with a severity of 10 or less is returned by SQL Server. Messages that have a severity between 11 and 20 raise an error and messages that have a severity over 20 causes the connection to close. For more information on SQL Server error levels, see [Database Engine Error Severities](/sql/relational-databases/errors-events/database-engine-error-severities). + + For more information and an example, see [Connection Events](~/docs/framework/data/adonet/connection-events.md). + + ]]> + + + + To be added. + To be added. + To be added. + + + Opens a database connection with the property settings specified by the . + + draws an open connection from the connection pool if one is available. Otherwise, it establishes a new connection to an instance of SQL Server. + +> [!NOTE] +> If the goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling . + +> [!NOTE] +> If you specify a port number other than 1433 when you are trying to connect to an instance of SQL Server and using a protocol other than TCP/IP, the method fails. To specify a port number other than 1433, include "server=machinename,port number" in the connection string, and use the TCP/IP protocol. + +> [!NOTE] +> The .NET Framework Data Provider for SQL Server requires the Security permission with "Allows calls to unmanaged assemblies" enabled ( with set to `UnmanagedCode`) to open a with SQL Debugging enabled. + + + +## Examples + The following example creates a , opens it, and displays some of its properties. The connection is automatically closed at the end of the `using` block. + + [!code-csharp[SqlConnection_Open Example#1](~/sqlclient/doc/samples/SqlConnection_Open.cs#1)] + + ]]> + + Cannot open a connection without specifying a data source or server. + + or + + The connection is already open. + A connection-level error occurred while opening the connection. If the property contains the value 18487 or 18488, this indicates that the specified password has expired or must be reset. See the method for more information. + + The tag in the app.config file has invalid or unknown elements. + There are two entries with the same name in the section. + + + The cancellation instruction. + An asynchronous version of , which opens a database connection with the property settings specified by the . The cancellation token can be used to request that the operation be abandoned before the connection timeout elapses. Exceptions will be propagated via the returned Task. If the connection timeout time elapses without successfully connecting, the returned Task will be marked as faulted with an Exception. The implementation returns a Task without blocking the calling thread for both pooled and non-pooled connections. + A task representing the asynchronous operation. + + , must return until the returned is completed. Then, if the connection was successful, must return . If the connection fails, must return . + + A call to will attempt to cancel or close the corresponding call. + + For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](~/docs/framework/data/adonet/asynchronous-programming.md). + + ]]> + + Calling more than once for the same instance before task completion. + + is specified in the connection string. + + A connection was not available from the connection pool before the connection time out elapsed. + Any error returned by SQL Server that occurred while opening the connection. + + + Gets the size (in bytes) of network packets used to communicate with an instance of SQL Server. + The size (in bytes) of network packets. The default value is 8000. + + ), which is sufficient for most data transfer operations. For most applications, the default packet size is best. + + may be a value in the range of 512 and 32767 bytes. An exception is generated if the value is outside this range. + + Setting the default value to a number greater than 8000 will cause the packets to use the MultiPage allocator on the instance of SQL Server instead of the much more efficient SinglePage allocator, reducing the overall scalability of the SQL Server. For more information on how SQL Server uses memory, see [Memory Management Architecture Guide](/sql/relational-databases/memory-management-architecture-guide). + + + +## Examples + The following example creates a , including setting the `Packet Size` to 512 in the connection string. It displays the and properties in the console window. + + [!code-csharp[SqlConnection_PacketSize Example#1](~/sqlclient/doc/samples/SqlConnection_PacketSize.cs#1)] + + ]]> + + + + Custom column encryption key provider dictionary + Registers the column encryption key store providers. This function should only be called once in an app. This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set. + + customKeyStoreProviders = new Dictionary(); + MySqlClientHSMProvider myProvider = new MySqlClientHSMProvider(); + customKeyStoreProviders.Add(@"HSM Provider", myProvider); + SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customKeyStoreProviders); + ``` + ]]> + + + + If statistics gathering is enabled, all values are reset to zero. + + + + + + Returns a name value pair collection of statistics at the point in time the method is called. + Returns a reference of type of items. + + + + + + Gets a string that contains the version of the instance of SQL Server to which the client is connected. + The version of the instance of SQL Server. + + was called while the returned Task was not completed and the connection was not opened after a call to . + + + +## Examples + The following example creates a and displays the property. + + [!code-csharp[SqlConnection_ServerVersion Example#1](~/sqlclient/doc/samples/SqlConnection_ServerVersion.cs#1)] + + ]]> + + The connection is closed. + + was called while the returned Task was not completed and the connection was not opened after a call to . + + + Indicates the state of the during the most recent network operation performed on the connection. + An enumeration. + + enumeration indicating the state of the . Closing and reopening the connection will refresh the value of . + + ]]> + + + + Occurs when the state of the connection changes. + + + When set to , enables statistics gathering for the current connection. + Returns if statistics gathering is enabled; otherwise . is the default. + + + + + + Begins a database transaction. + An object that represents the new transaction. + + or method. +]]> + + + + One of the values. + Begins a database transaction with the specified value. + An object that represents the new transaction. + + or method. +]]> + + + + Creates and returns a Command object that is associated with the connection. + A Command object that is associated with the connection. + To be added. + + + Creates a new object that is a copy of the current instance. + A new object that is a copy of this instance. + + instance is cast to an interface. + + This member is only supported by the .NET Compact Framework. + + ]]> + + + + Gets a string that identifies the database client. + A string that identifies the database client. If not specified, the name of the client computer. If neither is specified, the value is an empty string. + + property corresponds to the `Workstation ID` connection string property. + + + +## Examples + The following example creates a and displays the property. + + [!code-csharp[SqlConnection_WorkstationId Example#1](~/sqlclient/doc/samples/SqlConnection_WorkstationId.cs#1)] + + ]]> + + +
+
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index 85515e2043..8c095d0d86 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -25,6 +25,7 @@ namespace Microsoft.Data.SqlClient { + /// public sealed partial class SqlConnection : DbConnection, ICloneable { static SqlConnection() @@ -106,24 +107,23 @@ private static readonly ConcurrentDictionary> _ColumnEncry capacity: 1, comparer: StringComparer.OrdinalIgnoreCase); - /// - /// Defines whether query metadata caching is enabled. - /// + /// public static TimeSpan ColumnEncryptionKeyCacheTtl { get; set; } = TimeSpan.FromHours(2); - /// - /// Defines whether query metadata caching is enabled. - /// + /// public static bool ColumnEncryptionQueryMetadataCacheEnabled { get; set; } = true; + /// public static IDictionary> ColumnEncryptionTrustedMasterKeyPaths => _ColumnEncryptionTrustedMasterKeyPaths; + /// public SqlConnection(string connectionString) : this() { ConnectionString = connectionString; // setting connection string first so that ConnectionOption is available CacheConnectionStringProperties(); } + /// public SqlConnection(string connectionString, SqlCredential credential) : this() { ConnectionString = connectionString; @@ -235,18 +235,7 @@ internal bool IsColumnEncryptionSettingEnabled } } - /// - /// This function should only be called once in an app. This does shallow copying of the dictionary so that - /// the app cannot alter the custom provider list once it has been set. - /// - /// Example: - /// - /// Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>(); - /// MySqlClientHSMProvider myProvider = new MySqlClientHSMProvider(); - /// customKeyStoreProviders.Add(@"HSM Provider", myProvider); - /// SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customKeyStoreProviders); - /// - /// Custom column encryption key provider dictionary + /// public static void RegisterColumnEncryptionKeyStoreProviders(IDictionary customProviders) { @@ -318,6 +307,7 @@ private void CacheConnectionStringProperties() // PUBLIC PROPERTIES // + /// // used to start/stop collection of statistics data and do verify the current state // // devnote: start/stop should not performed using a property since it requires execution of code @@ -327,8 +317,6 @@ private void CacheConnectionStringProperties() // Create a new SqlStatistics object if not already there. // connect the parser to the object. // if there is no parser at this time we need to connect it after creation. - // - public bool StatisticsEnabled { get @@ -428,6 +416,7 @@ internal int ConnectRetryInterval get => ((SqlConnectionString)ConnectionOptions).ConnectRetryInterval; } + /// public override string ConnectionString { get @@ -454,6 +443,7 @@ public override string ConnectionString } } + /// public override int ConnectionTimeout { get @@ -463,6 +453,7 @@ public override int ConnectionTimeout } } + /// // AccessToken: To be used for token based authentication public string AccessToken { @@ -494,6 +485,7 @@ public string AccessToken } } + /// public override string Database { // if the connection is open, we need to ask the inner connection what it's @@ -517,6 +509,7 @@ public override string Database } } + /// public override string DataSource { get @@ -537,6 +530,7 @@ public override string DataSource } } + /// public int PacketSize { // if the connection is open, we need to ask the inner connection what it's @@ -560,6 +554,7 @@ public int PacketSize } } + /// public Guid ClientConnectionId { get @@ -582,11 +577,13 @@ public Guid ClientConnectionId } } + /// public override string ServerVersion { get => GetOpenTdsConnection().ServerVersion; } + /// public override ConnectionState State { get @@ -606,6 +603,7 @@ internal SqlStatistics Statistics get => _statistics; } + /// public string WorkstationId { get @@ -619,6 +617,7 @@ public string WorkstationId } } + /// public SqlCredential Credential { get @@ -706,6 +705,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S } } + /// protected override DbProviderFactory DbProviderFactory { get => SqlClientFactory.Instance; @@ -717,8 +717,10 @@ protected override DbProviderFactory DbProviderFactory // PUBLIC EVENTS // + /// public event SqlInfoMessageEventHandler InfoMessage; + /// public bool FireInfoMessageEventOnUserErrors { get => _fireInfoMessageEventOnUserErrors; @@ -733,6 +735,7 @@ internal int ReconnectCount internal bool ForceNewConnection { get; set; } + /// protected override void OnStateChange(StateChangeEventArgs stateChange) { if (!_suppressStateChangeForReconnection) @@ -744,19 +747,21 @@ protected override void OnStateChange(StateChangeEventArgs stateChange) // // PUBLIC METHODS // - + /// new public SqlTransaction BeginTransaction() { // this is just a delegate. The actual method tracks executiontime return BeginTransaction(System.Data.IsolationLevel.Unspecified, null); } + /// new public SqlTransaction BeginTransaction(System.Data.IsolationLevel iso) { // this is just a delegate. The actual method tracks executiontime return BeginTransaction(iso, null); } + /// public SqlTransaction BeginTransaction(string transactionName) { // Use transaction names only on the outermost pair of nested @@ -766,6 +771,7 @@ public SqlTransaction BeginTransaction(string transactionName) return BeginTransaction(System.Data.IsolationLevel.Unspecified, transactionName); } + /// [SuppressMessage("Microsoft.Reliability", "CA2004:RemoveCallsToGCKeepAlive")] override protected DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) { @@ -780,6 +786,7 @@ override protected DbTransaction BeginDbTransaction(System.Data.IsolationLevel i return transaction; } + /// public SqlTransaction BeginTransaction(System.Data.IsolationLevel iso, string transactionName) { WaitForPendingReconnection(); @@ -812,6 +819,7 @@ public SqlTransaction BeginTransaction(System.Data.IsolationLevel iso, string tr } } + /// public override void ChangeDatabase(string database) { SqlStatistics statistics = null; @@ -827,11 +835,13 @@ public override void ChangeDatabase(string database) } } + /// public static void ClearAllPools() { SqlConnectionFactory.SingletonInstance.ClearAllPools(); } + /// public static void ClearPool(SqlConnection connection) { ADP.CheckArgumentNull(connection, nameof(connection)); @@ -854,6 +864,7 @@ private void CloseInnerConnection() InnerConnection.CloseConnection(this, ConnectionFactory); } + /// public override void Close() { ConnectionState previousState = State; @@ -930,6 +941,7 @@ public override void Close() } } + /// new public SqlCommand CreateCommand() { return new SqlCommand(null, this); @@ -957,7 +969,7 @@ private void DisposeMe(bool disposing) } } - + /// public override void Open() { Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); @@ -1204,6 +1216,7 @@ private void CancelOpenAndWait() Debug.Assert(_currentCompletion == null, "After waiting for an async call to complete, there should be no completion source"); } + /// public override Task OpenAsync(CancellationToken cancellationToken) { Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); @@ -1285,16 +1298,19 @@ public override Task OpenAsync(CancellationToken cancellationToken) } } + /// public override DataTable GetSchema() { return GetSchema(DbMetaDataCollectionNames.MetaDataCollections, null); } + /// public override DataTable GetSchema(string collectionName) { return GetSchema(collectionName, null); } + /// public override DataTable GetSchema(string collectionName, string[] restrictionValues) { return InnerConnection.GetSchema(ConnectionFactory, PoolGroup, this, collectionName, restrictionValues); @@ -1647,7 +1663,7 @@ internal void OnInfoMessage(SqlInfoMessageEventArgs imevent, out bool notified) } } - + /// public static void ChangePassword(string connectionString, string newPassword) { if (string.IsNullOrEmpty(connectionString)) @@ -1678,6 +1694,7 @@ public static void ChangePassword(string connectionString, string newPassword) ChangePassword(connectionString, connectionOptions, null, newPassword, null); } + /// public static void ChangePassword(string connectionString, SqlCredential credential, SecureString newSecurePassword) { if (string.IsNullOrEmpty(connectionString)) @@ -1766,7 +1783,7 @@ internal void RegisterForConnectionCloseNotification(ref Task outerTask, o }, TaskScheduler.Default).Unwrap(); } - + /// public void ResetStatistics() { if (null != Statistics) @@ -1780,6 +1797,7 @@ public void ResetStatistics() } } + /// public IDictionary RetrieveStatistics() { if (null != Statistics) @@ -1804,6 +1822,7 @@ private void UpdateStatistics() Statistics.UpdateStatistics(); } + /// object ICloneable.Clone() => new SqlConnection(this); private void CopyFrom(SqlConnection connection) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index 9dae1a0e19..2b4ffa16bd 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -23,7 +23,7 @@ public sealed partial class SqlConnection : DbConnection private DbConnectionInternal _innerConnection; private int _closeCount; - + /// public SqlConnection() : base() { GC.SuppressFinalize(this); @@ -130,6 +130,7 @@ internal void AddWeakReference(object value, int tag) InnerConnection.AddWeakReference(value, tag); } + /// override protected DbCommand CreateDbCommand() { DbCommand command = null; @@ -139,7 +140,7 @@ override protected DbCommand CreateDbCommand() return command; } - + /// override protected void Dispose(bool disposing) { if (disposing) @@ -154,6 +155,7 @@ override protected void Dispose(bool disposing) partial void RepairInnerConnection(); + /// public override void EnlistTransaction(Transaction transaction) { // If we're currently enlisted in a transaction and we were called diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs index 1e64061282..222a78ee17 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs @@ -27,6 +27,7 @@ public sealed partial class SqlConnection : DbConnection private static int _objectTypeCount; // Bid counter internal readonly int ObjectID = System.Threading.Interlocked.Increment(ref _objectTypeCount); + /// public SqlConnection() : base() { GC.SuppressFinalize(this); @@ -195,7 +196,7 @@ internal void AddWeakReference(object value, int tag) InnerConnection.AddWeakReference(value, tag); } - + /// override protected DbCommand CreateDbCommand() { DbCommand command = null; @@ -221,6 +222,7 @@ private static System.Security.CodeAccessPermission CreateExecutePermission() return p; } + /// override protected void Dispose(bool disposing) { if (disposing) @@ -266,6 +268,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans GC.KeepAlive(this); } + /// override public void EnlistTransaction(SysTx.Transaction transaction) { SqlConnection.ExecutePermission.Demand(); @@ -316,16 +319,19 @@ internal DbMetaDataFactory GetMetaDataFactoryInternal(DbConnectionInternal inter return GetMetaDataFactory(internalConnection); } + /// override public DataTable GetSchema() { return this.GetSchema(DbMetaDataCollectionNames.MetaDataCollections, null); } + /// override public DataTable GetSchema(string collectionName) { return this.GetSchema(collectionName, null); } + /// override public DataTable GetSchema(string collectionName, string[] restrictionValues) { // NOTE: This is virtual because not all providers may choose to support diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs index 7e91a4bd4d..7a59d3a645 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -36,6 +36,7 @@ namespace Microsoft.Data.SqlClient { using Microsoft.Data.Common; + /// [DefaultEvent("InfoMessage")] public sealed partial class SqlConnection : DbConnection, ICloneable { @@ -94,6 +95,7 @@ static private readonly ConcurrentDictionary> _ColumnEncry capacity: 1, comparer: StringComparer.OrdinalIgnoreCase); + /// [ DefaultValue(null), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -112,6 +114,7 @@ static public IDictionary> ColumnEncryptionTrustedMasterKe /// static private bool _ColumnEncryptionQueryMetadataCacheEnabled = true; + /// [ DefaultValue(null), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -134,6 +137,7 @@ static public bool ColumnEncryptionQueryMetadataCacheEnabled /// static private TimeSpan _ColumnEncryptionKeyCacheTtl = TimeSpan.FromHours(2); + /// [ DefaultValue(null), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -151,18 +155,7 @@ static public TimeSpan ColumnEncryptionKeyCacheTtl } } - /// - /// This function should only be called once in an app. This does shallow copying of the dictionary so that - /// the app cannot alter the custom provider list once it has been set. - /// - /// Example: - /// - /// Dictionary customKeyStoreProviders = new Dictionary(); - /// MySqlClientHSMProvider myProvider = new MySqlClientHSMProvider(); - /// customKeyStoreProviders.Add(@"HSM Provider", myProvider); - /// SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customKeyStoreProviders); - /// - /// Custom column encryption key provider dictionary + /// static public void RegisterColumnEncryptionKeyStoreProviders(IDictionary customProviders) { @@ -310,10 +303,12 @@ static internal List GetColumnEncryptionCustomKeyStoreProviders() // using SqlConnection.Open() method. internal bool _applyTransientFaultHandling = false; + /// public SqlConnection(string connectionString) : this(connectionString, null) { } + /// public SqlConnection(string connectionString, SqlCredential credential) : this() { ConnectionString = connectionString; // setting connection string first so that ConnectionOption is available @@ -389,6 +384,7 @@ private void CacheConnectionStringProperties() // PUBLIC PROPERTIES // + /// // used to start/stop collection of statistics data and do verify the current state // // devnote: start/stop should not performed using a property since it requires execution of code @@ -398,8 +394,6 @@ private void CacheConnectionStringProperties() // Create a new SqlStatistics object if not already there. // connect the parser to the object. // if there is no parser at this time we need to connect it after creation. - // - [ DefaultValue(false), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -583,6 +577,7 @@ internal int ConnectRetryInterval } } + /// override protected DbProviderFactory DbProviderFactory { get @@ -632,6 +627,7 @@ public string AccessToken } } + /// [ DefaultValue(""), #pragma warning disable 618 // ignore obsolete warning about RecommendedAsConfigurable to use SettingsBindableAttribute @@ -677,6 +673,7 @@ override public string ConnectionString } } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlConnection_ConnectionTimeout), @@ -690,6 +687,7 @@ override public int ConnectionTimeout } } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ResDescriptionAttribute(StringsHelper.ResourceNames.SqlConnection_Database), @@ -717,6 +715,7 @@ override public string Database } } + /// [ Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), @@ -742,6 +741,7 @@ override public string DataSource } } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -775,6 +775,7 @@ public int PacketSize } } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -803,6 +804,7 @@ public Guid ClientConnectionId } } + /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), @@ -816,6 +818,7 @@ override public string ServerVersion } } + /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), @@ -843,6 +846,7 @@ internal SqlStatistics Statistics } } + /// [ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_Data), @@ -872,6 +876,7 @@ public string WorkstationId } } + /// // SqlCredential: Pair User Id and password in SecureString which are to be used for SQL authentication [ Browsable(false), @@ -988,6 +993,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S // PUBLIC EVENTS // + /// [ ResCategoryAttribute(StringsHelper.ResourceNames.DataCategory_InfoMessage), ResDescriptionAttribute(StringsHelper.ResourceNames.DbConnection_InfoMessage), @@ -1004,6 +1010,7 @@ public event SqlInfoMessageEventHandler InfoMessage } } + /// public bool FireInfoMessageEventOnUserErrors { get @@ -1067,19 +1074,21 @@ internal int ReconnectCount // // PUBLIC METHODS // - + /// new public SqlTransaction BeginTransaction() { // this is just a delegate. The actual method tracks executiontime return BeginTransaction(IsolationLevel.Unspecified, null); } + /// new public SqlTransaction BeginTransaction(IsolationLevel iso) { // this is just a delegate. The actual method tracks executiontime return BeginTransaction(iso, null); } + /// public SqlTransaction BeginTransaction(string transactionName) { // Use transaction names only on the outermost pair of nested @@ -1089,6 +1098,7 @@ public SqlTransaction BeginTransaction(string transactionName) return BeginTransaction(IsolationLevel.Unspecified, transactionName); } + /// // suppress this message - we cannot use SafeHandle here. Also, see notes in the code (VSTFDEVDIV# 560355) [SuppressMessage("Microsoft.Reliability", "CA2004:RemoveCallsToGCKeepAlive")] override protected DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) @@ -1115,6 +1125,7 @@ override protected DbTransaction BeginDbTransaction(IsolationLevel isolationLeve } } + /// public SqlTransaction BeginTransaction(IsolationLevel iso, string transactionName) { WaitForPendingReconnection(); @@ -1155,6 +1166,7 @@ public SqlTransaction BeginTransaction(IsolationLevel iso, string transactionNam } } + /// override public void ChangeDatabase(string database) { SqlStatistics statistics = null; @@ -1205,12 +1217,14 @@ override public void ChangeDatabase(string database) } } + /// static public void ClearAllPools() { (new SqlClientPermission(PermissionState.Unrestricted)).Demand(); SqlConnectionFactory.SingletonInstance.ClearAllPools(); } + /// static public void ClearPool(SqlConnection connection) { ADP.CheckArgumentNull(connection, "connection"); @@ -1227,6 +1241,7 @@ static public void ClearPool(SqlConnection connection) } } + /// object ICloneable.Clone() { SqlConnection clone = new SqlConnection(this); @@ -1244,6 +1259,7 @@ void CloseInnerConnection() InnerConnection.CloseConnection(this, ConnectionFactory); } + /// override public void Close() { IntPtr hscp; @@ -1336,6 +1352,7 @@ override public void Close() } } + /// new public SqlCommand CreateCommand() { return new SqlCommand(null, this); @@ -1366,6 +1383,7 @@ private void DisposeMe(bool disposing) } } + /// public void EnlistDistributedTransaction(System.EnterpriseServices.ITransaction transaction) { if (IsContextConnection) @@ -1376,6 +1394,7 @@ public void EnlistDistributedTransaction(System.EnterpriseServices.ITransaction EnlistDistributedTransactionHelper(transaction); } + /// override public void Open() { IntPtr hscp; @@ -1632,6 +1651,7 @@ void CancelOpenAndWait() Debug.Assert(_currentCompletion == null, "After waiting for an async call to complete, there should be no completion source"); } + /// public override Task OpenAsync(CancellationToken cancellationToken) { IntPtr hscp; @@ -2407,7 +2427,7 @@ private void IssueSQLDebug(uint option, string machineName, uint pid, uint id, s c.ExecuteNonQuery(); } - + /// public static void ChangePassword(string connectionString, string newPassword) { IntPtr hscp; @@ -2455,6 +2475,7 @@ public static void ChangePassword(string connectionString, string newPassword) } } + /// public static void ChangePassword(string connectionString, SqlCredential credential, SecureString newSecurePassword) { IntPtr hscp; @@ -2569,6 +2590,7 @@ static private void RefreshMemoryMappedData(SqlDebugContext sdc) sdc.data = memMap.rgbData; } + /// public void ResetStatistics() { if (IsContextConnection) @@ -2587,6 +2609,7 @@ public void ResetStatistics() } } + /// public IDictionary RetrieveStatistics() { if (IsContextConnection) From 207e0121872bfed5609a8eed799d80f9ba5da47a Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 17 Sep 2019 16:44:37 -0700 Subject: [PATCH 19/19] replace using SDS with MDS in samples --- doc/samples/SqlCommand_ExecuteNonQuery.cs | 9 ++++----- doc/samples/SqlConnection_BeginTransaction1.cs | 8 ++++---- doc/samples/SqlConnection_BeginTransaction3.cs | 9 ++++----- doc/samples/SqlConnection_ConnectionString.cs | 7 +++---- doc/samples/SqlConnection_ConnectionString1.cs | 4 ++-- doc/samples/SqlConnection_ConnectionTimeout.cs | 9 ++++----- doc/samples/SqlConnection_CreateCommand.cs | 4 ++-- doc/samples/SqlConnection_DataSource.cs | 9 ++++----- doc/samples/SqlConnection_Database.cs | 9 ++++----- doc/samples/SqlConnection_Open.cs | 9 ++++----- doc/samples/SqlConnection_PacketSize.cs | 9 ++++----- doc/samples/SqlConnection_ServerVersion.cs | 8 ++++---- doc/samples/SqlConnection_SqlConnection.cs | 8 ++++---- doc/samples/SqlConnection_SqlConnection1.cs | 9 ++++----- doc/samples/SqlConnection_WorkstationId.cs | 9 ++++----- 15 files changed, 55 insertions(+), 65 deletions(-) diff --git a/doc/samples/SqlCommand_ExecuteNonQuery.cs b/doc/samples/SqlCommand_ExecuteNonQuery.cs index 5b90d9c14d..16a5b474c1 100644 --- a/doc/samples/SqlCommand_ExecuteNonQuery.cs +++ b/doc/samples/SqlCommand_ExecuteNonQuery.cs @@ -1,7 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; - +// +using Microsoft.Data.SqlClient; namespace SqlCommandCS { @@ -14,7 +14,6 @@ static void Main() string qs = "SELECT OrderID, CustomerID FROM dbo.Orders;"; CreateCommand(qs, str); } - // private static void CreateCommand(string queryString, string connectionString) { @@ -26,6 +25,6 @@ private static void CreateCommand(string queryString, command.ExecuteNonQuery(); } } - // } -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_BeginTransaction1.cs b/doc/samples/SqlConnection_BeginTransaction1.cs index 5e8be105ca..c7b7b6b651 100644 --- a/doc/samples/SqlConnection_BeginTransaction1.cs +++ b/doc/samples/SqlConnection_BeginTransaction1.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -11,7 +12,6 @@ static void Main() ExecuteSqlTransaction(connectionString); Console.ReadLine(); } - // private static void ExecuteSqlTransaction(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -61,5 +61,5 @@ private static void ExecuteSqlTransaction(string connectionString) } } } - // -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_BeginTransaction3.cs b/doc/samples/SqlConnection_BeginTransaction3.cs index 3398405f13..44eb020ff7 100644 --- a/doc/samples/SqlConnection_BeginTransaction3.cs +++ b/doc/samples/SqlConnection_BeginTransaction3.cs @@ -1,7 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; - +// +using Microsoft.Data.SqlClient; namespace Transaction1CS { @@ -14,7 +14,6 @@ static void Main() ExecuteSqlTransaction(connectionString); Console.ReadLine(); } - // private static void ExecuteSqlTransaction(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -65,6 +64,6 @@ private static void ExecuteSqlTransaction(string connectionString) } } } - // } -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_ConnectionString.cs b/doc/samples/SqlConnection_ConnectionString.cs index f7c6e10f9e..0b5ed5a00b 100644 --- a/doc/samples/SqlConnection_ConnectionString.cs +++ b/doc/samples/SqlConnection_ConnectionString.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -10,7 +11,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection() { string connectionString = GetConnectionString(); @@ -34,6 +34,5 @@ static private string GetConnectionString() return "Data Source=MSSQL1;Initial Catalog=AdventureWorks;" + "Integrated Security=true;"; } - // - } +// diff --git a/doc/samples/SqlConnection_ConnectionString1.cs b/doc/samples/SqlConnection_ConnectionString1.cs index 8aaedcfe06..c587c162f5 100644 --- a/doc/samples/SqlConnection_ConnectionString1.cs +++ b/doc/samples/SqlConnection_ConnectionString1.cs @@ -1,7 +1,7 @@ -// using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { diff --git a/doc/samples/SqlConnection_ConnectionTimeout.cs b/doc/samples/SqlConnection_ConnectionTimeout.cs index 410a27c46b..0ad488ebde 100644 --- a/doc/samples/SqlConnection_ConnectionTimeout.cs +++ b/doc/samples/SqlConnection_ConnectionTimeout.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -10,7 +11,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection() { string connectionString = GetConnectionString(); @@ -31,6 +31,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;Connection Timeout=30"; } - // - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_CreateCommand.cs b/doc/samples/SqlConnection_CreateCommand.cs index e2ce0147ad..f8146a9917 100644 --- a/doc/samples/SqlConnection_CreateCommand.cs +++ b/doc/samples/SqlConnection_CreateCommand.cs @@ -1,6 +1,6 @@ -// using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; public class A { public static void Main() { using (SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;")) { diff --git a/doc/samples/SqlConnection_DataSource.cs b/doc/samples/SqlConnection_DataSource.cs index 6230d62bf7..779a5af14f 100644 --- a/doc/samples/SqlConnection_DataSource.cs +++ b/doc/samples/SqlConnection_DataSource.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program1 { @@ -12,7 +13,6 @@ static void Mainx() Console.ReadLine(); } - // private static void OpenSqlConnection(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -22,7 +22,6 @@ private static void OpenSqlConnection(string connectionString) Console.WriteLine("DataSource: {0}", connection.DataSource); } } - // static private string GetConnectionString() { @@ -32,5 +31,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_Database.cs b/doc/samples/SqlConnection_Database.cs index 46ba57fac8..4cedb11b22 100644 --- a/doc/samples/SqlConnection_Database.cs +++ b/doc/samples/SqlConnection_Database.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program1 { @@ -12,7 +13,6 @@ static void Main() Console.ReadLine(); } - // private static void ChangeSqlDatabase(string connectionString) { // Assumes connectionString represents a valid connection string @@ -27,7 +27,6 @@ private static void ChangeSqlDatabase(string connectionString) Console.WriteLine("Database: {0}", connection.Database); } } - // static private string GetConnectionString() { @@ -37,5 +36,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_Open.cs b/doc/samples/SqlConnection_Open.cs index d2aca4d9b8..932b17fe3f 100644 --- a/doc/samples/SqlConnection_Open.cs +++ b/doc/samples/SqlConnection_Open.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program1 { @@ -12,7 +13,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -22,7 +22,6 @@ private static void OpenSqlConnection(string connectionString) Console.WriteLine("State: {0}", connection.State); } } - // static private string GetConnectionString() { @@ -32,5 +31,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_PacketSize.cs b/doc/samples/SqlConnection_PacketSize.cs index 6311ece08e..7503818c30 100644 --- a/doc/samples/SqlConnection_PacketSize.cs +++ b/doc/samples/SqlConnection_PacketSize.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -10,7 +11,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection() { string connectionString = GetConnectionString(); @@ -30,6 +30,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;Packet Size=512"; } - // - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_ServerVersion.cs b/doc/samples/SqlConnection_ServerVersion.cs index 1cf19c961f..2572dbf60e 100644 --- a/doc/samples/SqlConnection_ServerVersion.cs +++ b/doc/samples/SqlConnection_ServerVersion.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; namespace SqlConnection1CS { @@ -13,7 +14,6 @@ static void Main() CreateSqlConnection(connectionString); Console.ReadLine(); } - // private static void CreateSqlConnection(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -23,6 +23,6 @@ private static void CreateSqlConnection(string connectionString) Console.WriteLine("State: {0}", connection.State ); } } - // } -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_SqlConnection.cs b/doc/samples/SqlConnection_SqlConnection.cs index 8c053a3661..59e5587e5a 100644 --- a/doc/samples/SqlConnection_SqlConnection.cs +++ b/doc/samples/SqlConnection_SqlConnection.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -10,7 +11,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection() { string connectionString = GetConnectionString(); @@ -30,5 +30,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - // -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_SqlConnection1.cs b/doc/samples/SqlConnection_SqlConnection1.cs index c1803a6454..19a9d5c5a5 100644 --- a/doc/samples/SqlConnection_SqlConnection1.cs +++ b/doc/samples/SqlConnection_SqlConnection1.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -10,7 +11,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection() { string connectionString = GetConnectionString(); @@ -33,6 +33,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - // - -} \ No newline at end of file +} +// diff --git a/doc/samples/SqlConnection_WorkstationId.cs b/doc/samples/SqlConnection_WorkstationId.cs index b5267ffb31..2edd6d878f 100644 --- a/doc/samples/SqlConnection_WorkstationId.cs +++ b/doc/samples/SqlConnection_WorkstationId.cs @@ -1,6 +1,7 @@ using System; using System.Data; -using System.Data.SqlClient; +// +using Microsoft.Data.SqlClient; class Program { @@ -12,7 +13,6 @@ static void Main() Console.ReadLine(); } - // private static void OpenSqlConnection(string connectionString) { using (SqlConnection connection = new SqlConnection(connectionString)) @@ -22,7 +22,6 @@ private static void OpenSqlConnection(string connectionString) Console.WriteLine("WorkstationId: {0}", connection.WorkstationId); } } - // static private string GetConnectionString() { @@ -32,5 +31,5 @@ static private string GetConnectionString() return "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;"; } - -} \ No newline at end of file +} +//