diff --git a/snippets/csharp/System.Data/EntityKey/Overview/app.config b/snippets/csharp/System.Data/EntityKey/Overview/app.config index bc5cd770d42..936b73f4837 100644 --- a/snippets/csharp/System.Data/EntityKey/Overview/app.config +++ b/snippets/csharp/System.Data/EntityKey/Overview/app.config @@ -1,7 +1,7 @@  - - + + - \ No newline at end of file + diff --git a/snippets/csharp/System.IdentityModel.Services/SessionAuthenticationModule/Overview/web.config.backup.1 b/snippets/csharp/System.IdentityModel.Services/SessionAuthenticationModule/Overview/web.config.backup.1 deleted file mode 100644 index 4e807904ac4..00000000000 --- a/snippets/csharp/System.IdentityModel.Services/SessionAuthenticationModule/Overview/web.config.backup.1 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/csharp/System.IdentityModel.Services/SignInRequestMessage/Overview/web.config.backup.1 b/snippets/csharp/System.IdentityModel.Services/SignInRequestMessage/Overview/web.config.backup.1 deleted file mode 100644 index 4e807904ac4..00000000000 --- a/snippets/csharp/System.IdentityModel.Services/SignInRequestMessage/Overview/web.config.backup.1 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/csharp/System.IdentityModel.Services/WSFederationAuthenticationModule/Overview/web.config.backup.1 b/snippets/csharp/System.IdentityModel.Services/WSFederationAuthenticationModule/Overview/web.config.backup.1 deleted file mode 100644 index 4e807904ac4..00000000000 --- a/snippets/csharp/System.IdentityModel.Services/WSFederationAuthenticationModule/Overview/web.config.backup.1 +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/csharp/System/Random/Overview/project.csproj b/snippets/csharp/System/Random/Overview/project.csproj index 00e2eb9594d..5ec2e995f12 100644 --- a/snippets/csharp/System/Random/Overview/project.csproj +++ b/snippets/csharp/System/Random/Overview/project.csproj @@ -3,8 +3,6 @@ Library net8.0 - enable - enable - - \ No newline at end of file + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcCommand/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcCommand/CS/source.cs index 3fee1b2cb1c..d533e0a3ff5 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcCommand/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcCommand/CS/source.cs @@ -4,10 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - } // public void InsertRow(string connectionString, string insertSQL) { @@ -31,6 +27,6 @@ public void InsertRow(string connectionString, string insertSQL) // The connection is automatically closed when the // code exits the using block. } - // } + // } diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/CS/source.cs index 3c0ac36c465..432ea039af5 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/CS/source.cs @@ -4,11 +4,6 @@ class Program { - static void Main() - { - string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - ExecuteTransaction(connectionString); - } // public static void ExecuteTransaction(string connectionString) { @@ -61,6 +56,6 @@ public static void ExecuteTransaction(string connectionString) // The connection is automatically closed when the // code exits the using block. } - // } + // } diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/CS/source.cs index 3c0ac36c465..432ea039af5 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/CS/source.cs @@ -4,11 +4,6 @@ class Program { - static void Main() - { - string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - ExecuteTransaction(connectionString); - } // public static void ExecuteTransaction(string connectionString) { @@ -61,6 +56,6 @@ public static void ExecuteTransaction(string connectionString) // The connection is automatically closed when the // code exits the using block. } - // } + // } diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/CS/source.cs index e5d7180cabd..53ec3b2ac53 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/CS/source.cs @@ -7,14 +7,6 @@ namespace Classic_WebData_OdbcConnection.CloseCS { class Program { - static void Main(string[] args) - { - string connectionString; - connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - - CreateOdbcConnection(connectionString); - } - // private static void CreateOdbcConnection(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/CS/source.cs index 7f7abb85a06..5767b6b5c32 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/CS/source.cs @@ -7,14 +7,6 @@ namespace Classic_WebData_OdbcConnectionCS { class Program { - static void Main() - { - string connectionString; - connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - - InsertRow(connectionString); - } - // static private void InsertRow(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/CS/source.cs index 773df29712d..d0501376f81 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/CS/source.cs index 21004c745d1..924e2ee4879 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/CS/source.cs @@ -4,11 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - } - // public DataSet GetDataSetFromAdapter( DataSet dataSet, string connectionString, string queryString) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/CS/source.cs index b557a3aa06f..976d0d76abb 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/CS/source.cs @@ -4,12 +4,6 @@ class Program { - static void Main() - { - //string connectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Samples\\Northwind.mdb"; - //string x = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=Northwind;" - } - // public DataSet GetDataSetFromAdapter( DataSet dataSet, string connectionString, string queryString) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/CS/source.cs index 4d87fc4a868..846bfa072a3 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/CS/source.cs @@ -8,8 +8,7 @@ class Program { static void Main() { - string connectionString = "Provider=sqloledb;Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; + string connectionString = "Provider=sqloledb;Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI"; string queryString = "UPDATE Shippers SET CompanyName = 'Speedy Expresss' WHERE ShipperID = 1"; CreateOleDbCommand(queryString, connectionString); Console.ReadLine(); diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/CS/source.cs index dbe5c864f62..4fffeecc2a8 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/CS/source.cs @@ -6,14 +6,6 @@ namespace OleDbCommandPrepareCS { class Program { - static void Main() - { - string connectionString = "Provider=sqloledb;Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - OleDbCommandPrepare(connectionString); - Console.ReadLine(); - } - // private static void OleDbCommandPrepare(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/CS/source.cs index 85ae4b28733..d5fe617a207 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/CS/source.cs @@ -4,12 +4,6 @@ class Class1 { - static void Main() - { - string x = "Provider=SQLOLEDB;Data Source=(local);Integrated Security=SSPI;Initial Catalog=Northwind"; - ReadData(x); - } - // public static void ReadData(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/CS/source.cs index 22c5a754ba9..ebedc213c33 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/CS/source.cs @@ -4,11 +4,6 @@ class Class1 { - static void Main() - { - // string x = "Provider=SQLOLEDB;Data Source=(local);Integrated Security=SSPI;Initial Catalog=Northwind"; - } - // public DataSet GetDataSetFromAdapter( DataSet dataSet, string connectionString, string queryString) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/CS/source.cs index 38156804352..d259578fe2c 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/CS/source.cs @@ -8,12 +8,6 @@ namespace SqlCommandCS { class Program { - static void Main() - { - string str = "Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - ReadOrderData(str); - } // private static void ReadOrderData(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/CS/source.cs index 4873c00fc33..284cb57db85 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/CS/source.cs @@ -8,13 +8,6 @@ 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) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/CS/source.cs index edf79e116b5..533faeaf9aa 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/CS/source.cs @@ -8,13 +8,6 @@ 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) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/Project.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/Project.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/Project.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/source.cs index 637d58e1814..7a7a86378db 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader Example/CS/source.cs @@ -6,13 +6,6 @@ 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) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/Project.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/Project.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/Project.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/mysample.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/mysample.cs index 125349bed1b..0d3ab12e91d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/mysample.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteReader2/CS/mysample.cs @@ -6,13 +6,6 @@ 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) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/CS/mysample.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/CS/mysample.cs index 9939d177711..1f84d49dddc 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/CS/mysample.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/CS/mysample.cs @@ -6,14 +6,6 @@ class Program { - static void Main() - { - string str = "Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - string qs = "SELECT OrderID, CustomerID FROM dbo.Orders;"; - string q = "SELECT * FROM dbo.Customers FOR XML AUTO, XMLDATA"; - CreateXMLReader(q, str); - } // private static void CreateXMLReader(string queryString, string connectionString) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/CS/Source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/CS/Source.cs index f2755c1a916..24de3ae7c0f 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/CS/Source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/CS/Source.cs @@ -6,12 +6,6 @@ namespace SqlPrepareCS { class Program { - static void Main() - { - string connectionString = "Persist Security Info=False;Integrated Security=SSPI;database=Northwind;server=(local)"; - SqlCommandPrepareEx(connectionString); - Console.ReadLine(); - } // private static void SqlCommandPrepareEx(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.SqlCommand2 Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.SqlCommand2 Example/CS/source.cs index 37d5549806d..d2b5ecffdd7 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.SqlCommand2 Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlCommand.SqlCommand2 Example/CS/source.cs @@ -8,13 +8,6 @@ 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) diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/Project.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/Project.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/Project.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/source.cs index 7c1bf2110a6..8f520e65ab9 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction Example/CS/source.cs @@ -6,13 +6,6 @@ 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) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/CS/source.cs index ba2fc1da85a..6fc3c7ee3ce 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/CS/source.cs @@ -4,13 +4,6 @@ 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) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/Project.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/Project.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/Project.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/source.cs index 5d9481de004..a5d8137f8ac 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction2 Example/CS/source.cs @@ -6,13 +6,6 @@ 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) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/Project.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/Project.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/Project.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/source.cs index 526a9b14528..af32b2bbdb2 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction3 Example/CS/source.cs @@ -6,13 +6,6 @@ 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) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/CS/source.cs index 5df069e85c2..39227080837 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/CS/source.cs @@ -5,12 +5,6 @@ class Program { - static void Main() - { - string str = "Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - ReadOrderData(str); - } // private static void ReadOrderData(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/CS/source.cs index b8cac5fefd1..26e9b09fb95 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/CS/source.cs @@ -5,13 +5,6 @@ class Program { - static void Main() - { - string str = "Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - ReadGetOrdinal(str); - } - // private static void ReadGetOrdinal(string connectionString) { diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/SqlDataReader.Read.csproj b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/SqlDataReader.Read.csproj index 9de5f49321c..b8fcb56ef9d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/SqlDataReader.Read.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/SqlDataReader.Read.csproj @@ -1,7 +1,7 @@ - Exe + Library net8.0 diff --git a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/source.cs index d124ecf4cf6..576c7339184 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Read Example/CS/source.cs @@ -1,17 +1,10 @@ -// -using System; +using System; using System.Data; using System.Data.SqlClient; class Program { - static void Main() - { - string str = "Data Source=(local);Initial Catalog=Northwind;" - + "Integrated Security=SSPI"; - ReadOrderData(str); - } - + // private static void ReadOrderData(string connectionString) { string queryString = @@ -41,5 +34,5 @@ private static void ReadSingleRow(IDataRecord dataRecord) { Console.WriteLine(String.Format("{0}, {1}", dataRecord[0], dataRecord[1])); } + // } -// \ No newline at end of file diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/LINQtoDataSetExamplesCS.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/LINQtoDataSetExamplesCS.csproj index 160408c37bf..f424ed69192 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/LINQtoDataSetExamplesCS.csproj +++ b/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/LINQtoDataSetExamplesCS.csproj @@ -1,60 +1,18 @@ - - + + - Debug - AnyCPU - 9.0.20829 - 2.0 - {404E1785-83BF-4026-B6D7-DC2AA2228D3F} Exe - Properties - DP_LINQ_to_DataSet_Examples - DP LINQ to DataSet Examples - v3.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net4.8 + 11 + - - - 3.5 - - - - 3.5 - - - 3.5 - - - + + - - + + - - - \ No newline at end of file + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Program.cs b/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Program.cs index f5919ba1d81..b8eedad6b24 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Program.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Program.cs @@ -1,14 +1,12 @@ // using System; -using System.Linq; -using System.Linq.Expressions; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using System.Data.Common; using System.Globalization; -// +using System.Linq; using System.Windows.Forms; +// namespace LINQtoDataSetSamples { @@ -2624,8 +2622,7 @@ static void FillDataSet(DataSet ds) // Create a new adapter and give it a query to fetch sales order, contact, // address, and product information for sales in the year 2002. Point connection // information to the configuration setting "AdventureWorks". - string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;" - + "Integrated Security=true;"; + string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=true;"; SqlDataAdapter da = new SqlDataAdapter( "SELECT SalesOrderID, ContactID, OrderDate, OnlineOrderFlag, " + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Properties/AssemblyInfo.cs b/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Properties/AssemblyInfo.cs deleted file mode 100644 index cd871ea62ac..00000000000 --- a/snippets/csharp/VS_Snippets_ADO.NET/DP LINQ to DataSet Examples/CS/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("DP LINQ to DataSet Examples")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("msft")] -[assembly: AssemblyProduct("DP LINQ to DataSet Examples")] -[assembly: AssemblyCopyright("Copyright © msft 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("98861c2d-73b2-44ca-9382-3ae1e7839cd4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/CS/source.cs deleted file mode 100644 index e899747029f..00000000000 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/CS/source.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Data; -using System.Data.Common; - -namespace ConBuilderAddCS -{ - class Program - { - // - static void Main() - { - try - { - DbConnectionStringBuilder builder = - new DbConnectionStringBuilder(); - builder.Add("Data Source", "ServerName"); - builder.Add("Initial Catalog", "TheDatabase"); - builder.Add("User ID", "UserName"); - builder.Add("Password", "*******"); - builder.Add("Command Logging", false); - - // Overwrite the existing "User ID" value. - builder.Add("User ID", "NewUserName"); - - // The following code would trigger - // an ArgumentNullException: - // builder.Add(null, "Some Value"); - - Console.WriteLine(builder.ConnectionString); - } - catch (ArgumentNullException) - { - Console.WriteLine("Null key values are not allowed."); - } - - Console.WriteLine("Press Enter to continue."); - Console.ReadLine(); - } - // - } -} diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/CS/source.cs index 45e4307be0b..a90c8768e63 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/CS/source.cs @@ -15,7 +15,6 @@ static void Main() DbConnectionStringBuilder(); builder.Add("Data Source", @"c:\MyData\MyDb.mdb"); builder.Add("Provider", "Microsoft.Jet.Oledb.4.0"); - builder.Add("Jet OLEDB:Database Password", "********"); builder.Add("Jet OLEDB:System Database", @"c:\MyData\Workgroup.mdb"); @@ -62,10 +61,6 @@ static void Main() { Console.WriteLine("Invalid connection string."); } - - Console.WriteLine(); - Console.WriteLine("Press Enter to finish."); - Console.ReadLine(); } // } diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/Project.csproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.ConnectionString/Project.csproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/Project.csproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/Project.csproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/source.cs index 7d4c4e7aa1d..6e535e54309 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder/CS/source.cs @@ -8,15 +8,13 @@ namespace ConBuilderCS { class Program { - // static void Main() { + // DbConnectionStringBuilder builder = new DbConnectionStringBuilder(); builder.ConnectionString = @"Data Source=c:\MyData\MyDb.mdb"; builder.Add("Provider", "Microsoft.Jet.Oledb.4.0"); - builder.Add("Jet OLEDB:Database Password", "*******"); - builder.Add("Jet OLEDB:System Database", @"c:\MyData\Workgroup.mdb"); // Set up row-level locking. builder.Add("Jet OLEDB:Database Locking Mode", 1); @@ -26,7 +24,7 @@ static void Main() // build any type of connection string using // this class. - // The ConnectionString property may have been + // The ConnectionString property might have been // formatted by the DbConnectionStringBuilder class. OleDbConnection oledbConnect = new OleDbConnection(builder.ConnectionString); @@ -46,25 +44,13 @@ static void Main() // Pass the DbConnectionStringBuilder an existing // connection string, and you can retrieve and // modify any of the elements. - builder.ConnectionString = "server=(local);user id=*******;" + - "password=*******;initial catalog=AdventureWorks"; + builder.ConnectionString = "server=(local);initial catalog=AdventureWorks"; builder["Server"] = "."; - builder.Remove("User ID"); - // Note that calling Remove on a nonexistent item doesn't - // throw an exception. - builder.Remove("BadItem"); - - // Setting the indexer adds the value if - // necessary. + // Setting the indexer adds the value, if necessary. builder["Integrated Security"] = true; - builder.Remove("password"); - builder["User ID"] = "Hello"; Console.WriteLine(builder.ConnectionString); - - Console.WriteLine("Press Enter to finish."); - Console.ReadLine(); + // } - // } } diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/CS/source.cs deleted file mode 100644 index 6f2f4cda7b2..00000000000 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/CS/source.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Data; -// -using System.Data.OleDb; - -class Program -{ - static void Main() - { - OleDbConnectionStringBuilder builder = - new OleDbConnectionStringBuilder(); - builder.ConnectionString = @"Data Source=c:\Sample.mdb"; - - // Call the Add method to explicitly add key/value - // pairs to the internal collection. - builder.Add("Provider", "Microsoft.Jet.Oledb.4.0"); - builder.Add("Jet OLEDB:Database Password", "MyPassword!"); - builder.Add("Jet OLEDB:System Database", @"C:\Workgroup.mdb"); - - // set up row-level locking. - builder.Add("Jet OLEDB:Database Locking Mode", 1); - - // Dump the contents of the "filled-in" - // OleDbConnectionStringBuilder - // to the console window. - DumpBuilderContents(builder); - - // Clear current values and reset known keys to their - // default values. - builder.Clear(); - - // Dump the contents of the newly emptied - // OleDbConnectionStringBuilder - // to the console window. - DumpBuilderContents(builder); - - Console.WriteLine("Press Enter to continue."); - Console.ReadLine(); - } - - private static void DumpBuilderContents(OleDbConnectionStringBuilder builder) - { - Console.WriteLine("================="); - Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString); - foreach (string key in builder.Keys) - { - Console.WriteLine(key + "=" + builder[key].ToString()); - } - } -} -// diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/Project.csproj new file mode 100644 index 00000000000..ccdf2c3dbe0 --- /dev/null +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/Project.csproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/source.cs index fbc5fe5a81d..b5ad7718737 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Item/CS/source.cs @@ -11,7 +11,6 @@ static void Main() builder.Provider = "Microsoft.Jet.Oledb.4.0"; builder.DataSource = @"C:\Sample.mdb"; // Set properties using the Item property (the indexer, in C#). - builder["Jet OLEDB:Database Password"] = "DataPassword"; builder["Jet OLEDB:Encrypt Database"] = true; builder["Jet OLEDB:System database"] = @"C:\Workgroup.mdw"; diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/Project.csproj new file mode 100644 index 00000000000..71b447cd8fe --- /dev/null +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/Project.csproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs index 32e115e4e0d..c99ec880366 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs @@ -13,15 +13,9 @@ static void Main() new OracleConnectionStringBuilder(GetConnectionString()); Console.WriteLine("Connection string = " + builder.ConnectionString); - // Keys you have provided return true. + // Keys you've provided return true. Console.WriteLine(builder.ContainsKey("Integrated Security")); - // Comparison is case insensitive, and synonyms for the - // keywords are translated to well-known names. - // The following returns true because "PWD" is a - // synonym for "Password", a valid key. - Console.WriteLine(builder.ContainsKey("PWD")); - // Keys that are valid but have not been set return true. Console.WriteLine(builder.ContainsKey("Unicode")); diff --git a/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/Project.csproj b/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/Project.csproj new file mode 100644 index 00000000000..1a9c4110a6a --- /dev/null +++ b/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/Project.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8 + + + + + + + + + diff --git a/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/source.cs b/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/source.cs index fd77b30bd3a..327ca79b93d 100644 --- a/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/source.cs +++ b/snippets/csharp/VS_Snippets_ADO.NET/idatareader_nextresult/cs/source.cs @@ -5,95 +5,102 @@ using System.Data.OleDb; using System.Data.Odbc; -class Program { - static void Main(string[] args) { - - // string connectionTypeName = "SqlClient"; - // string connectionString = @"Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI"; - - // string connectionTypeName = "Odbc"; - // string connectionString = @"Driver={SQL Server Native Client 11.0};Server=(local);Database=AdventureWorks2012;Trusted_Connection=Yes"; - - string connectionTypeName = "OleDb"; - string connectionString = @"Provider=SQLNCLI11;Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI"; - - using (IDbConnection connection = DatabaseConnectionFactory.GetConnection(connectionTypeName, connectionString)) { - IDbCommand command = connection.CreateCommand(); - command.Connection = connection; - - // these 2 queries are executed as a single batch and return 2 separate results - command.CommandText = "SELECT CountryRegionCode, Name FROM Person.CountryRegion;" + "SELECT CountryRegionCode, StateProvinceCode, Name, StateProvinceID FROM Person.StateProvince;"; - - connection.Open(); - - using (IDataReader reader = command.ExecuteReader()) { - - // process the first result - displayCountryRegions(reader); - - // use NextResult to move to the second result and verify it is returned - if (!reader.NextResult()) - throw new InvalidOperationException("Expected second result (StateProvinces) but only one was returned"); - - // process the second result - displayStateProvinces(reader); - - reader.Close(); - } - - connection.Close(); - } - } - - static void displayCountryRegions(IDataReader reader) { - if (reader.FieldCount != 2) - throw new InvalidOperationException("First resultset (CountryRegions) must contain exactly 2 columns"); - - while (reader.Read()) { - Console.WriteLine("CountryRegionCode={0}, Name={1}" - , reader.GetString(reader.GetOrdinal("CountryRegionCode")) - , reader.GetString(reader.GetOrdinal("Name"))); - } - } - - static void displayStateProvinces(IDataReader reader) { - if (reader.FieldCount != 4) - throw new InvalidOperationException("Second resultset (StateProvinces) must contain exactly 4 columns"); - - while (reader.Read()) { - Console.WriteLine("CountryRegionCode={0}, StateProvinceCode={1}, Name={2}, StateProvinceID={3}" - , reader.GetString(reader.GetOrdinal("CountryRegionCode")) - , reader.GetString(reader.GetOrdinal("StateProvinceCode")) - , reader.GetString(reader.GetOrdinal("Name")) - , reader.GetInt32(reader.GetOrdinal("StateProvinceID"))); - } - } - - class DatabaseConnectionFactory { - static SqlConnection GetSqlConnection(string connectionString) { - return new SqlConnection(connectionString); - } - - static OdbcConnection GetOdbcConnection(string connectionString) { - return new OdbcConnection(connectionString); - } - - static OleDbConnection GetOleDbConnection(string connectionString) { - return new OleDbConnection(connectionString); - } - - public static IDbConnection GetConnection(string connectionTypeName, string connectionString) { - switch (connectionTypeName) { - case "SqlClient": - return GetSqlConnection(connectionString); - case "Odbc": - return GetOdbcConnection(connectionString); - case "OleDb": - return GetOleDbConnection(connectionString); - default: - throw new ArgumentException("Value must be SqlClient, Odbc or OleDb", "connectionTypeName"); - } - } - } +class Program +{ + static void Main(string[] args) + { + string connectionTypeName = "OleDb"; + string connectionString = @"Provider=SQLNCLI11;Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI"; + + using (IDbConnection connection = DatabaseConnectionFactory.GetConnection(connectionTypeName, connectionString)) + { + IDbCommand command = connection.CreateCommand(); + command.Connection = connection; + + // these 2 queries are executed as a single batch and return 2 separate results + command.CommandText = "SELECT CountryRegionCode, Name FROM Person.CountryRegion;" + "SELECT CountryRegionCode, StateProvinceCode, Name, StateProvinceID FROM Person.StateProvince;"; + + connection.Open(); + + using (IDataReader reader = command.ExecuteReader()) + { + + // process the first result + displayCountryRegions(reader); + + // use NextResult to move to the second result and verify it is returned + if (!reader.NextResult()) + throw new InvalidOperationException("Expected second result (StateProvinces) but only one was returned"); + + // process the second result + displayStateProvinces(reader); + + reader.Close(); + } + + connection.Close(); + } + } + + static void displayCountryRegions(IDataReader reader) + { + if (reader.FieldCount != 2) + throw new InvalidOperationException("First resultset (CountryRegions) must contain exactly 2 columns"); + + while (reader.Read()) + { + Console.WriteLine("CountryRegionCode={0}, Name={1}" + , reader.GetString(reader.GetOrdinal("CountryRegionCode")) + , reader.GetString(reader.GetOrdinal("Name"))); + } + } + + static void displayStateProvinces(IDataReader reader) + { + if (reader.FieldCount != 4) + throw new InvalidOperationException("Second resultset (StateProvinces) must contain exactly 4 columns"); + + while (reader.Read()) + { + Console.WriteLine("CountryRegionCode={0}, StateProvinceCode={1}, Name={2}, StateProvinceID={3}" + , reader.GetString(reader.GetOrdinal("CountryRegionCode")) + , reader.GetString(reader.GetOrdinal("StateProvinceCode")) + , reader.GetString(reader.GetOrdinal("Name")) + , reader.GetInt32(reader.GetOrdinal("StateProvinceID"))); + } + } + + class DatabaseConnectionFactory + { + static SqlConnection GetSqlConnection(string connectionString) + { + return new SqlConnection(connectionString); + } + + static OdbcConnection GetOdbcConnection(string connectionString) + { + return new OdbcConnection(connectionString); + } + + static OleDbConnection GetOleDbConnection(string connectionString) + { + return new OleDbConnection(connectionString); + } + + public static IDbConnection GetConnection(string connectionTypeName, string connectionString) + { + switch (connectionTypeName) + { + case "SqlClient": + return GetSqlConnection(connectionString); + case "Odbc": + return GetOdbcConnection(connectionString); + case "OleDb": + return GetOleDbConnection(connectionString); + default: + throw new ArgumentException("Value must be SqlClient, Odbc, or OleDb", "connectionTypeName"); + } + } + } } -// \ No newline at end of file +// diff --git a/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConfigurationStringSettings.cs b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConfigurationStringSettings.cs index 516cb501693..74d4f344b27 100644 --- a/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConfigurationStringSettings.cs +++ b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConfigurationStringSettings.cs @@ -1,17 +1,12 @@ // using System; -using System.Collections.Generic; using System.Configuration; using System.Web.Configuration; -using System.Collections; -using System.Text; namespace ConfigurationStringSettings { - class ConfigurationStringSettings { - static void DisplayConnectionStrings() { // Set the path of the config file. @@ -64,4 +59,4 @@ static void Main(string[] args) } } } -// \ No newline at end of file +// diff --git a/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs index 17012e93d5a..5806f9c06ef 100644 --- a/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs +++ b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs @@ -1,14 +1,12 @@ using System; using System.Configuration; -using System.Text; namespace Samples.AspNet { class ConnectionStrings { - // - // Create a connectionn string element and add it to + // Create a connection string element and add it to // the connection strings section. static ConnectionStrings() { @@ -18,20 +16,20 @@ static ConnectionStrings() ConfigurationUserLevel.None); // Get the current connection strings count. - int connStrCnt = + int connStrCnt = ConfigurationManager.ConnectionStrings.Count; - - // Create the connection string name. - string csName = + + // Create the connection string name. + string csName = "ConnStr" + connStrCnt.ToString(); // Create a connection string element and // save it to the configuration file. - + // Create a connection string element. ConnectionStringSettings csSettings = new ConnectionStringSettings(csName, - "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;" + + "LocalSqlServer: data source=127.0.0.1;Integrated Security=True;" + "Initial Catalog=aspnetdb", "System.Data.SqlClient"); // Get the connection strings section. @@ -40,7 +38,7 @@ static ConnectionStrings() // Add the new element. csSection.ConnectionStrings.Add(csSettings); - + // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); } @@ -49,35 +47,33 @@ static ConnectionStrings() // static void ShowConnectionStrings() { - // Get the application configuration file. + // Get the application configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // - // Get the conectionStrings section. + // Get the connectionStrings section. ConnectionStringsSection csSection = config.ConnectionStrings; - - for (int i = 0; i < + + for (int i = 0; i < ConfigurationManager.ConnectionStrings.Count; i++) { - ConnectionStringSettings cs = + ConnectionStringSettings cs = csSection.ConnectionStrings[i]; - + // - Console.WriteLine(" Connection String: \"{0}\"", - cs.ConnectionString); + Console.WriteLine($" Connection String: \"{cs.ConnectionString}\""); // - Console.WriteLine("#{0}", i); + Console.WriteLine($"#{i}"); // - Console.WriteLine(" Name: {0}", cs.Name); + Console.WriteLine($" Name: {cs.Name}"); // // - Console.WriteLine(" Provider Name: {0}", - cs.ProviderName); + Console.WriteLine($" Provider Name: {cs.ProviderName}"); // } // @@ -90,27 +86,27 @@ static void ShowConnectionStrings() // configuration file. static void AddConnectionStrings() { - + // Get the count of the connection strings. - int connStrCnt = + int connStrCnt = ConfigurationManager.ConnectionStrings.Count; - + // Define the string name. - string csName = "ConnStr" + + string csName = "ConnStr" + connStrCnt.ToString(); // Get the configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); - + // // Add the connection string. ConnectionStringsSection csSection = config.ConnectionStrings; csSection.ConnectionStrings.Add( new ConnectionStringSettings(csName, - "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;" + + "LocalSqlServer: data source=127.0.0.1;Integrated Security=True;" + "Initial Catalog=aspnetdb", "System.Data.SqlClient")); // @@ -135,7 +131,7 @@ static void ClearConnectionStrings() ConnectionStringsSection csSection = config.ConnectionStrings; csSection.ConnectionStrings.Clear(); - + // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); @@ -168,7 +164,7 @@ static void GetIndex() int index = csCollection.IndexOf(cs); Console.WriteLine( - "Connection string settings index: {0}", + "Connection string settings index: {0}", index.ToString()); } catch (ConfigurationErrorsException err) @@ -207,7 +203,7 @@ static void RemoveConnectionStrings() // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); - + Console.WriteLine( "Connection string settings removed."); } @@ -239,7 +235,7 @@ static void RemoveConnectionStrings2() csSection.ConnectionStrings; // Remove the element. - csCollection.Remove("ConnStr0"); + csCollection.Remove("ConnStr0"); // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); @@ -275,7 +271,7 @@ static void RemoveConnectionStrings3() // Save the configuration file. config.Save(ConfigurationSaveMode.Modified); - + Console.WriteLine( "Connection string settings removed."); } @@ -337,7 +333,7 @@ static void GetItems2() // with the specified name. ConnectionStringSettings cs = csCollection["ConnStr0"]; - + Console.WriteLine( "cs: {0}", cs.Name); } @@ -350,7 +346,7 @@ static void GetItems2() static void Main(string[] args) { - + // Display current connection strings. // ShowConnectionStrings(); diff --git a/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/Project.csproj b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/Project.csproj new file mode 100644 index 00000000000..fb21df9241f --- /dev/null +++ b/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/Project.csproj @@ -0,0 +1,16 @@ + + + + Library + net4.8 + + + + + + + + + + + diff --git a/snippets/csharp/VS_Snippets_WebNet/System.Web.Configuration.WebConfigurationManager/CS/WebConfigurationManager.cs b/snippets/csharp/VS_Snippets_WebNet/System.Web.Configuration.WebConfigurationManager/CS/WebConfigurationManager.cs index 07da1561c3a..4311bf38fef 100644 --- a/snippets/csharp/VS_Snippets_WebNet/System.Web.Configuration.WebConfigurationManager/CS/WebConfigurationManager.cs +++ b/snippets/csharp/VS_Snippets_WebNet/System.Web.Configuration.WebConfigurationManager/CS/WebConfigurationManager.cs @@ -11,11 +11,11 @@ namespace Samples.Aspnet class UsingWebConfigurationManager { - // Methods to access a section at runtime. + // Methods to access a section at runtime. // - // Show how to use the GetSection(string). + // Show how to use the GetSection(string). // to access the connectionStrings section. static void GetConnectionStringsSection() { @@ -28,12 +28,12 @@ static void GetConnectionStringsSection() // Get the connectionStrings key,value pairs collection. ConnectionStringSettingsCollection connectionStrings = connectionStringsSection.ConnectionStrings; - + // Get the collection enumerator. IEnumerator connectionStringsEnum = connectionStrings.GetEnumerator(); - // Loop through the collection and + // Loop through the collection and // display the connectionStrings key, value pairs. int i = 0; Console.WriteLine("[Display the connectionStrings]"); @@ -52,14 +52,14 @@ static void GetConnectionStringsSection() // - // Show the use of GetSection(string, string). + // Show the use of GetSection(string, string). // to access the connectionStrings section. static void GetSection2() { try { - // Get the connectionStrings section for the + // Get the connectionStrings section for the // specified Web app. This GetSection overload // can olny be called from within a Web application. ConnectionStringsSection connectionStringsSection = @@ -74,7 +74,7 @@ static void GetSection2() IEnumerator connectionStringsEnum = connectionStrings.GetEnumerator(); - // Loop through the collection and + // Loop through the collection and // display the connectionStrings key, value pairs. int i = 0; Console.WriteLine("[Display connectionStrings]"); @@ -99,7 +99,7 @@ static void GetSection2() // - // Show the use of GetWebApplicationSection(string). + // Show the use of GetWebApplicationSection(string). // to get the connectionStrings section. static void GetWebApplicationSection() { @@ -117,7 +117,7 @@ static void GetWebApplicationSection() IEnumerator connectionStringsEnum = connectionStrings.GetEnumerator(); - // Loop through the collection and + // Loop through the collection and // display the connectionStrings key, value pairs. int i = 0; Console.WriteLine("[Display connectionStrings]"); @@ -150,7 +150,7 @@ static void GetConnectionStrings() IEnumerator connectionStringsEnum = connectionStrings.GetEnumerator(); - // Loop through the collection and + // Loop through the collection and // display the connectionStrings key, value pairs. int i = 0; Console.WriteLine("[Display connectionStrings]"); @@ -170,7 +170,7 @@ static void GetConnectionStrings() // // Show the use of the AppSettings property - // to get the application settings. + // to get the application settings. static void GetAppSettings() { @@ -183,7 +183,7 @@ static void GetAppSettings() IEnumerator appSettingsEnum = appSettings.GetEnumerator(); - // Loop through the collection and + // Loop through the collection and // display the appSettings key, value pairs. int i = 0; Console.WriteLine("[Display appSettings]"); @@ -200,15 +200,15 @@ static void GetAppSettings() // - // Methods to access configuration files + // Methods to access configuration files // not at runtime. These methods are // used to edit configuration files. // // Show how to use OpenMachineConfiguration(). - // It gets the machine.config file on the current - // machine and displays section information. + // It gets the machine.config file on the current + // machine and displays section information. static void OpenMachineConfiguration1() { // Get the machine.config file on the current machine. @@ -228,7 +228,7 @@ static void OpenMachineConfiguration1() Console.WriteLine("[Total number of sections: {0}]", i); // Display machine.config path. - Console.WriteLine("[File path: {0}]", config.FilePath); + Console.WriteLine("[File path: {0}]", config.FilePath); } // @@ -236,13 +236,13 @@ static void OpenMachineConfiguration1() // // Show how to use OpenMachineConfiguration(string). - // It gets the machine.config file applicabe to the - // specified resource and displays section - // basic information. + // It gets the machine.config file applicable to the + // specified resource and displays section + // basic information. static void OpenMachineConfiguration2() { - // Get the machine.config file applicabe to the - // specified reosurce. + // Get the machine.config file applicable to the + // specified resource. System.Configuration.Configuration config = WebConfigurationManager.OpenMachineConfiguration("configTest"); @@ -268,14 +268,14 @@ static void OpenMachineConfiguration2() // Show how to use OpenMachineConfiguration(string, string). // It gets the machine.config file on the specified server and - // applicabe to the specified reosurce and displays section - // basic information. + // applicable to the specified resource and displays section + // basic information. static void OpenMachineConfiguration3() { - // Get the machine.config file applicabe to the - // specified reosurce and on the specified server. + // Get the machine.config file applicable to the + // specified resource and on the specified server. System.Configuration.Configuration config = - WebConfigurationManager.OpenMachineConfiguration("configTest", + WebConfigurationManager.OpenMachineConfiguration("configTest", "myServer"); // Loop to get the sections. Display basic information. @@ -300,16 +300,16 @@ static void OpenMachineConfiguration3() // Show how to use OpenMachineConfiguration(string, string). // It gets the machine.config file on the specified server, - // applicabe to the specified reosurce, for the specified user - // and displays section basic information. + // applicable to the specified resource, for the specified user + // and displays section basic information. static void OpenMachineConfiguration4() { // Get the current user token. IntPtr userToken = System.Security.Principal.WindowsIdentity.GetCurrent().Token; - // Get the machine.config file applicabe to the - // specified reosurce, on the specified server for the + // Get the machine.config file applicable to the + // specified resource, on the specified server for the // specified user. System.Configuration.Configuration config = WebConfigurationManager.OpenMachineConfiguration("configTest", @@ -337,8 +337,8 @@ static void OpenMachineConfiguration4() // Show how to use OpenMachineConfiguration(string, string). // It gets the machine.config file on the specified server, - // applicabe to the specified reosurce, for the specified user - // and displays section basic information. + // applicable to the specified resource, for the specified user + // and displays section basic information. static void OpenMachineConfiguration5() { // Set the user id and password. @@ -347,8 +347,8 @@ static void OpenMachineConfiguration5() // Substitute with actual password. string password = "userPassword"; - // Get the machine.config file applicabe to the - // specified reosurce, on the specified server for the + // Get the machine.config file applicable to the + // specified resource, on the specified server for the // specified user. System.Configuration.Configuration config = WebConfigurationManager.OpenMachineConfiguration("configTest", @@ -375,15 +375,15 @@ static void OpenMachineConfiguration5() // // Show how to use OpenWebConfiguration(string). - // It gets he appSettings section of a Web application - // runnig on the local server. + // It gets he appSettings section of a Web application + // runnig on the local server. static void OpenWebConfiguration1() { // Get the configuration object for a Web application - // running on the local server. + // running on the local server. System.Configuration.Configuration config = - WebConfigurationManager.OpenWebConfiguration("/configTest") - as System.Configuration.Configuration; + WebConfigurationManager.OpenWebConfiguration("/configTest") + as System.Configuration.Configuration; // Get the appSettings. KeyValueConfigurationCollection appSettings = @@ -406,14 +406,14 @@ static void OpenWebConfiguration1() // // Show how to use OpenWebConfiguration(string, string). - // It gets he appSettings section of a Web application - // runnig on the local server. + // It gets he appSettings section of a Web application + // runnig on the local server. static void OpenWebConfiguration2() { // Get the configuration object for a Web application - // running on the local server. + // running on the local server. System.Configuration.Configuration config = - WebConfigurationManager.OpenWebConfiguration("/configTest", + WebConfigurationManager.OpenWebConfiguration("/configTest", "Default Web Site") as System.Configuration.Configuration; @@ -441,12 +441,12 @@ static void OpenWebConfiguration2() // // Show how to use OpenWebConfiguration(string, string, string). - // It gets he appSettings section of a Web application - // runnig on the local server. + // It gets he appSettings section of a Web application + // runnig on the local server. static void OpenWebConfiguration3() { // Get the configuration object for a Web application - // running on the local server. + // running on the local server. System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration( "/configTest", "Default Web Site", null) @@ -462,7 +462,7 @@ static void OpenWebConfiguration3() "[appSettings for app at: /configTest"); Console.WriteLine(" site: Default Web Site"); Console.WriteLine(" and locationSubPath: null]"); - + foreach (string key in appSettings.AllKeys) { Console.WriteLine("Name: {0} Value: {1}", @@ -476,22 +476,22 @@ static void OpenWebConfiguration3() // - // Show how to use OpenWebConfiguration(string, string, + // Show how to use OpenWebConfiguration(string, string, // string, string). - // It gets he appSettings section of a Web application - // running on the specified server. + // It gets he appSettings section of a Web application + // running on the specified server. // If the server is remote your application must have the - // required access rights to the configuration file. + // required access rights to the configuration file. static void OpenWebConfiguration4() { // Get the configuration object for a Web application // running on the specified server. - // Null for the subPath signifies no subdir. + // Null for the subPath signifies no subdir. System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration( "/configTest", "Default Web Site", null, "myServer") as System.Configuration.Configuration; - + // Get the appSettings. KeyValueConfigurationCollection appSettings = config.AppSettings.Settings; @@ -512,18 +512,18 @@ static void OpenWebConfiguration4() // - // Show how to use OpenWebConfiguration(string, string, + // Show how to use OpenWebConfiguration(string, string, // string, string, string, string). - // It gets he appSettings section of a Web application - // running on a remote server. + // It gets he appSettings section of a Web application + // running on a remote server. // If the server is remote your application must have the - // required access rights to the configuration file. + // required access rights to the configuration file. static void OpenWebConfiguration5() { // Get the current user. string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; - + // Assign the actual password. string password = "userPassword"; @@ -554,26 +554,26 @@ static void OpenWebConfiguration5() // - // Show how to use OpenWebConfiguration(string, string, + // Show how to use OpenWebConfiguration(string, string, // string, string, IntPtr). - // It gets he appSettings section of a Web application - // running on a remote server. + // It gets he appSettings section of a Web application + // running on a remote server. // If the serve is remote your application shall have the - // requires access rights to the configuration file. + // requires access rights to the configuration file. static void OpenWebConfiguration6() { - IntPtr userToken = + IntPtr userToken = System.Security.Principal.WindowsIdentity.GetCurrent().Token; - - string user = + + string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; - + // Get the configuration object for a Web application // running on a remote server. System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration( - "/configTest", "Default Web Site", null, + "/configTest", "Default Web Site", null, "myServer", userToken) as System.Configuration.Configuration; // Get the appSettings. @@ -597,7 +597,7 @@ static void OpenWebConfiguration6() // // Utility to map virtual directories to physical ones. - // In the current physical directory maps + // In the current physical directory maps // a physical sub-directory with its virtual directory. // A web.config file is created for the // default and the virtual directory at the appropriate level. @@ -611,24 +611,24 @@ static WebConfigurationFileMap CreateFileMap() // Get he physical directory where this app runs. // We'll use it to map the virtual directories - // defined next. + // defined next. string physDir = Environment.CurrentDirectory; // Create a VirtualDirectoryMapping object to use // as the root directory for the virtual directory - // named config. + // named config. // Note: you must assure that you have a physical subdirectory // named config in the curremt physical directory where this // application runs. - VirtualDirectoryMapping vDirMap = + VirtualDirectoryMapping vDirMap = new VirtualDirectoryMapping(physDir + "\\config", true); - // Add vDirMap to the VirtualDirectories collection + // Add vDirMap to the VirtualDirectories collection // assigning to it the virtual directory name. fileMap.VirtualDirectories.Add("/config", vDirMap); // Create a VirtualDirectoryMapping object to use - // as the default directory for all the virtual + // as the default directory for all the virtual // directories. VirtualDirectoryMapping vDirMapBase = new VirtualDirectoryMapping(physDir, true, "web.config"); @@ -636,15 +636,15 @@ static WebConfigurationFileMap CreateFileMap() // Add it to the virtual directory mapping collection. fileMap.VirtualDirectories.Add("/", vDirMapBase); -# if DEBUG +# if DEBUG // Test at debug time. foreach (string key in fileMap.VirtualDirectories.AllKeys) { Console.WriteLine("Virtual directory: {0} Physical path: {1}", - fileMap.VirtualDirectories[key].VirtualDirectory, + fileMap.VirtualDirectories[key].VirtualDirectory, fileMap.VirtualDirectories[key].PhysicalDirectory); } -# endif +# endif // Return the mapping. return fileMap; @@ -660,7 +660,7 @@ static void OpenMappedWebConfiguration1() { // Create the configuration directories mapping. - WebConfigurationFileMap fileMap = + WebConfigurationFileMap fileMap = CreateFileMap(); try @@ -669,10 +669,10 @@ static void OpenMappedWebConfiguration1() // Get the Configuration object for the mapped // virtual directory. System.Configuration.Configuration config = - WebConfigurationManager.OpenMappedWebConfiguration(fileMap, + WebConfigurationManager.OpenMappedWebConfiguration(fileMap, "/config"); - // Define a nique key for the creation of + // Define a nique key for the creation of // an appSettings element entry. int appStgCnt = config.AppSettings.Settings.Count; string asName = "AppSetting" + appStgCnt.ToString(); @@ -684,12 +684,12 @@ static void OpenMappedWebConfiguration1() // Save to the configuration file. config.Save(ConfigurationSaveMode.Modified); - + // Display new appSettings. Console.WriteLine("Count: [{0}]", config.AppSettings.Settings.Count); foreach (string key in config.AppSettings.Settings.AllKeys) - { - Console.WriteLine("[{0}] = [{1}]", key, + { + Console.WriteLine("[{0}] = [{1}]", key, config.AppSettings.Settings[key].Value); } } @@ -719,11 +719,11 @@ static void OpenMappedWebConfiguration2() // Get the Configuration object for the mapped // virtual directory. - System.Configuration.Configuration config = + System.Configuration.Configuration config = WebConfigurationManager.OpenMappedWebConfiguration( fileMap, "/config", "config"); - - // Define a nique key for the creation of + + // Define a nique key for the creation of // an appSettings element entry. int appStgCnt = config.AppSettings.Settings.Count; string asName = "AppSetting" + appStgCnt.ToString(); @@ -737,7 +737,7 @@ static void OpenMappedWebConfiguration2() config.Save(ConfigurationSaveMode.Modified); // Display new appSettings. - Console.WriteLine("Count: [{0}]", + Console.WriteLine("Count: [{0}]", config.AppSettings.Settings.Count); foreach (string key in config.AppSettings.Settings.AllKeys) { @@ -775,7 +775,7 @@ static void OpenMappedWebConfiguration3() WebConfigurationManager.OpenMappedWebConfiguration( fileMap, "/config", "config", "config"); - // Define a nique key for the creation of + // Define a unique key for the creation of // an appSettings element entry. int appStgCnt = config.AppSettings.Settings.Count; string asName = "AppSetting" + appStgCnt.ToString(); @@ -789,7 +789,7 @@ static void OpenMappedWebConfiguration3() config.Save(ConfigurationSaveMode.Modified); // Display new appSettings. - Console.WriteLine("Count: [{0}]", + Console.WriteLine("Count: [{0}]", config.AppSettings.Settings.Count); foreach (string key in config.AppSettings.Settings.AllKeys) { @@ -825,7 +825,7 @@ static void Main(string[] args) case "0": GetConnectionStringsSection(); break; - + case "1": GetSection2(); break; @@ -861,19 +861,19 @@ static void Main(string[] args) case "9": OpenWebConfiguration2(); break; - + case "10": OpenWebConfiguration3(); break; - + case "11": OpenWebConfiguration4(); break; - + case "12": OpenWebConfiguration5(); break; - + case "13": OpenWebConfiguration6(); break; @@ -893,7 +893,7 @@ static void Main(string[] args) case "17": GetAppSettings(); break; - + case "18": GetConnectionStrings(); break; @@ -907,4 +907,4 @@ static void Main(string[] args) } } } -// \ No newline at end of file +// diff --git a/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx b/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx deleted file mode 100644 index 46f7cc80601..00000000000 --- a/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx +++ /dev/null @@ -1,88 +0,0 @@ - -<%@Page Language="C#" %> -<%@Import Namespace="System.Data" %> -<%@Import Namespace="System.Data.Common" %> - - - - - - - - - ASP.NET Example - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/source.vb index 144197cbd47..de1f6feec43 100644 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/source.vb +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.BeginTransaction1/VB/source.vb @@ -35,10 +35,10 @@ Module Module1 command.Transaction = transaction ' Execute the commands. - command.CommandText = _ + command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')" command.ExecuteNonQuery() - command.CommandText = _ + command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')" command.ExecuteNonQuery() diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Close/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcConnection/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.DeleteCommand/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.InsertCommand/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter1/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter2/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.OdbcDataAdapter3/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.SelectCommand/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter.UpdateCommand/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcDataAdapter/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/VB/Project.vbproj new file mode 100644 index 00000000000..517d96c28c2 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OdbcParameter/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/Project.vbproj new file mode 100644 index 00000000000..ccdf2c3dbe0 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.ExecuteNonQuery Example/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/VB/Project.vbproj new file mode 100644 index 00000000000..ccdf2c3dbe0 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbCommand.Prepare Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/VB/Project.vbproj new file mode 100644 index 00000000000..ccdf2c3dbe0 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbDataReader.GetOrdinal/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/VB/Project.vbproj new file mode 100644 index 00000000000..ccdf2c3dbe0 --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData OleDbParameter Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Connection Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteNonQuery Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.ExecuteXmlReader/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlCommand.Prepare/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlConnection.BeginTransaction1 Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.Close Example/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/VB/Project.vbproj b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/VB/Project.vbproj new file mode 100644 index 00000000000..84455e1397c --- /dev/null +++ b/snippets/visualbasic/VS_Snippets_ADO.NET/Classic WebData SqlDataReader.GetOrdinal/VB/Project.vbproj @@ -0,0 +1,12 @@ + + + + Exe + net4.8 + + + + + + + diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/VB/source.vb deleted file mode 100644 index f71dd4caf2a..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/VB/source.vb +++ /dev/null @@ -1,36 +0,0 @@ -Option Explicit On -Option Strict On - -Imports System.Data -Imports System.Data.Common - -Module Module1 - ' - Sub Main() - Try - Dim builder As New DbConnectionStringBuilder - builder.Add("Data Source", "ServerName") - builder.Add("Initial Catalog", "TheDatabase") - builder.Add("User ID", "UserName") - builder.Add("Password", "*******") - builder.Add("Command Logging", False) - - ' Overwrite the existing "User ID" value. - builder.Add("User ID", "NewUserName") - - ' The following code would trigger - ' an ArgumentNullException. - ' builder.Add(Nothing, "Some Value") - - Console.WriteLine(builder.ConnectionString) - - Catch ex As ArgumentNullException - Console.WriteLine("Null key values are not allowed.") - End Try - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub - ' -End Module - diff --git a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/VB/source.vb b/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/VB/source.vb deleted file mode 100644 index 4c699e5f6da..00000000000 --- a/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/VB/source.vb +++ /dev/null @@ -1,48 +0,0 @@ -Option Explicit -Option Strict - -Imports System.Data -' -Imports System.Data.OleDb - -Module Module1 - Sub Main() - Dim builder As New OleDbConnectionStringBuilder() - builder.ConnectionString = "Data Source=C:\Sample.mdb" - - ' Call the Add method to explicitly add key/value - ' pairs to the internal collection. - builder.Add("Provider", "Microsoft.Jet.Oledb.4.0") - builder.Add("Jet OLEDB:Database Password", "MyPassword!") - builder.Add("Jet OLEDB:System Database", "C:\Workgroup.mdb") - - ' Set up row-level locking. - builder.Add("Jet OLEDB:Database Locking Mode", 1) - - ' Dump the contents of the "filled-in" OleDbConnectionStringBuilder - ' to the console window. - DumpBuilderContents(builder) - - ' Clear current values and reset known keywords to their - ' default values. - builder.Clear() - - ' Dump the contents of the newly emptied - ' OleDbConnectionStringBuilder - ' to the console window. - DumpBuilderContents(builder) - - Console.WriteLine("Press Enter to continue.") - Console.ReadLine() - End Sub - - Private Sub DumpBuilderContents(ByVal builder As OleDbConnectionStringBuilder) - Console.WriteLine("=================") - Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString) - For Each key As String In builder.Keys - Console.WriteLine(key & "=" & builder.Item(key).ToString) - Next - End Sub -End Module -' - diff --git a/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx b/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx deleted file mode 100644 index 37d9a17424b..00000000000 --- a/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx +++ /dev/null @@ -1,97 +0,0 @@ - -<%@Page Language="VB" %> -<%@Import Namespace="System.Data" %> -<%@Import Namespace="System.Data.Common" %> - - - - - - - ASP.NET Example - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xml/System.Configuration/ConfigurationManager.xml b/xml/System.Configuration/ConfigurationManager.xml index f1f2191ca87..c125e168d24 100644 --- a/xml/System.Configuration/ConfigurationManager.xml +++ b/xml/System.Configuration/ConfigurationManager.xml @@ -212,21 +212,6 @@ Module Module1 End Sub End Module -``` - - The previous example assumes your project has an App.config file as shown below. - -```xml - - - - - - - - - - ``` The following example shows how to use a connection string to read data from a database. @@ -291,20 +276,6 @@ Module Module1 End Sub End Module -``` - - The previous example assumes your project has an App.config as shown below. - -```xml - - - - - - - - - ``` ]]> @@ -510,21 +481,6 @@ Module Module1 End Sub End Module -``` - - The previous example assumes your project has an App.config file as shown below. - -```xml - - - - - - - - - - ``` ]]> @@ -632,20 +588,6 @@ Module Module1 End Sub End Module -``` - - The previous example assumes your project has an App.config as shown below. - -```xml - - - - - - - - - ``` ]]> diff --git a/xml/System.Configuration/ConnectionStringSettingsCollection.xml b/xml/System.Configuration/ConnectionStringSettingsCollection.xml index 8017ad75fc0..7c766ea57ac 100644 --- a/xml/System.Configuration/ConnectionStringSettingsCollection.xml +++ b/xml/System.Configuration/ConnectionStringSettingsCollection.xml @@ -38,31 +38,17 @@ Contains a collection of objects. - object contains a collection of objects. Each object represents a single entry in the `` configuration-file section. - - - -## Examples - The following example shows how to access the . - + object contains a collection of objects. Each object represents a single entry in the `` configuration-file section. + +## Examples + The following example shows how to access the . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet2"::: - - The following example is an excerpt from the configuration file used by the previous example. - -```xml - - - - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet2"::: + ]]> @@ -130,14 +116,14 @@ A object to add to the collection. Adds a object to the collection. - object to a collection. - + object to a collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet7"::: + ]]> @@ -210,19 +196,19 @@ Removes all the objects from the collection. - method removes all the connection strings from the configuration file at the current configuration hierarchy level and writes a `` tag in the file. The `` tag signifies that all the connection strings defined in the parent configuration files are disregarded by the system. - - - -## Examples - The following example shows how to remove all the objects from the collection. - + method removes all the connection strings from the configuration file at the current configuration hierarchy level and writes a `` tag in the file. The `` tag signifies that all the connection strings defined in the parent configuration files are disregarded by the system. + + + +## Examples + The following example shows how to remove all the objects from the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet9"::: + ]]> @@ -331,14 +317,14 @@ Returns the collection index of the passed object. The collection index of the specified object. - object. - + object. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet10"::: + ]]> @@ -388,19 +374,19 @@ Gets or sets the connection string at the specified index in the collection. The object at the specified index. - class. - - - -## Examples - The following example shows how to access a object at a given index in a collection. - + class. + + + +## Examples + The following example shows how to access a object at a given index in a collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet14"::: + ]]> @@ -440,19 +426,19 @@ Gets or sets the object with the specified name in the collection. The object with the specified name; otherwise, . - class. - - - -## Examples - The following example shows how to access a named object in a collection. - + class. + + + +## Examples + The following example shows how to access a named object in a collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet15"::: + ]]> @@ -536,14 +522,14 @@ A object in the collection. Removes the specified object from the collection. - object from the collection. - + object from the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet11"::: + ]]> @@ -582,14 +568,14 @@ The name of a object in the collection. Removes the specified object from the collection. - object with the specified name from the collection. - + object with the specified name from the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet12"::: + ]]> @@ -628,14 +614,14 @@ The index of a object in the collection. Removes the object at the specified index in the collection. - object at the specified index in the collection. - + object at the specified index in the collection. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet13"::: + ]]> diff --git a/xml/System.Configuration/ConnectionStringsSection.xml b/xml/System.Configuration/ConnectionStringsSection.xml index 21b889e13d0..94f683ce0be 100644 --- a/xml/System.Configuration/ConnectionStringsSection.xml +++ b/xml/System.Configuration/ConnectionStringsSection.xml @@ -32,31 +32,19 @@ Provides programmatic access to the connection strings configuration-file section. - class allows you to programmatically modify the `connectionStrings` section of the configuration file. The connection strings are provided as a of `add` configuration elements. - - - -## Examples - The following example shows how to use the . - + class allows you to programmatically modify the `connectionStrings` section of the configuration file. The connection strings are provided as a of `add` configuration elements. + + + +## Examples + The following example shows how to use the . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet1"::: - - The following excerpt shows the configuration used by the previous example. - -```xml - - - - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet1"::: + ]]> @@ -127,14 +115,14 @@ Gets a collection of objects. A collection of objects. - property of the object. - + property of the object. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/CS/ConnectionStrings.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConnectionStrings/VB/ConnectionStrings.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Configuration/ProtectedConfigurationProvider.xml b/xml/System.Configuration/ProtectedConfigurationProvider.xml index 262ed3b7187..94c905d2aa3 100644 --- a/xml/System.Configuration/ProtectedConfigurationProvider.xml +++ b/xml/System.Configuration/ProtectedConfigurationProvider.xml @@ -61,33 +61,6 @@ You can encrypt sections of a configuration file to protect sensitive informatio :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.UsingProtectedConfigurationProvider/CS/ProtectedConfigurationProvider.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.UsingProtectedConfigurationProvider/VB/ProtectedConfigurationProvider.vb" id="Snippet11"::: - The following is an excerpt of the configuration file used by the above examples. - -[!INCLUDE[ROPC warning](~/includes/ropc-warning.md)] - -```xml - - - - - - - - - - - - - - - - -``` - ]]> diff --git a/xml/System.Data.Common/DbConnectionStringBuilder.xml b/xml/System.Data.Common/DbConnectionStringBuilder.xml index 426afec405c..da880354bcf 100644 --- a/xml/System.Data.Common/DbConnectionStringBuilder.xml +++ b/xml/System.Data.Common/DbConnectionStringBuilder.xml @@ -81,17 +81,17 @@ ## Remarks The class provides the base class from which the strongly typed connection string builders (, , and so on) derive. The connection string builders let developers programmatically create syntactically correct connection strings, and parse and rebuild existing connection strings. - The has been defined in a database-agnostic manner. Because of the addition of the namespace, developers require a base class against which they can program in order to build connection strings that can work against an arbitrary database. Therefore, the class lets users assign arbitrary key/value pairs and pass the resulting connection string to a strongly typed provider. All the data providers that are included as part of the .NET Framework provide a strongly typed class that inherits from : , , , and . + The has been defined in a database-agnostic manner. Because of the addition of the namespace, developers require a base class against which they can program in order to build connection strings that can work against an arbitrary database. Therefore, the class lets users assign arbitrary key/value pairs and pass the resulting connection string to a strongly typed provider. All the data providers that are included as part of .NET offer a strongly typed class that inherits from : , , , and . - The developer can build, assign, and edit connection strings for any arbitrary provider. For providers that support specific key/value pairs, the connection string builder provides strongly typed properties corresponding to the known pairs. In order to support providers that require the ability to support unknown values, developers can also supply arbitrary key/value pairs. +You can build, assign, and edit connection strings for any arbitrary provider. For providers that support specific key/value pairs, the connection string builder provides strongly typed properties corresponding to the known pairs. For providers that require the ability to support unknown values, you can also supply arbitrary key/value pairs. - The class implements the interface. This means that the class works with Visual Studio designers at design time. When developers use the designer to build strongly typed DataSets and strongly typed connections within Visual Studio, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys. + The class implements the interface. This means that the class works with Visual Studio designers at design time. When developers use the designer to build strongly typed DataSets and strongly typed connections within Visual Studio, the strongly typed connection string builder class displays the properties associated with its type and also has converters that can map common values for known keys. - Developers needing to create connection strings as part of applications can use the class or one of its strongly typed derivatives to build and modify connection strings. The class also makes it easy to manage connection strings stored in an application configuration file. +If you need to create connection strings as part of applications, use the class or one of its strongly typed derivatives to build and modify connection strings. The class also makes it easy to manage connection strings stored in an application configuration file. - Developers can create connection strings using either a strongly typed connection string builder class, or they can use the class. The performs no checks for valid key/value pairs. Therefore, it is possible using this class to create invalid connection strings. The supports only key/value pairs that are supported by SQL Server; trying to add invalid pairs will throw an exception. +You can create connection strings using either a strongly typed connection string builder class or the class. The performs no checks for valid key/value pairs. Therefore, it's possible to create invalid connection strings when using this class. The supports only key/value pairs that are supported by SQL Server; trying to add invalid pairs will throw an exception. - Both the method and property handle tries to insert malicious entries. For example, the following code correctly escapes the nested key/value pair: + Both the method and property handle cases where a bad actor tries to insert malicious entries. For example, the following code correctly escapes the nested key/value pair: ```vb Dim builder As New System.Data.Common.DbConnectionStringBuilder @@ -277,17 +277,6 @@ initial catalog="AdventureWorks;NewValue=Bad" Calling the method by passing a null (`Nothing` in Visual Basic) key throws an . However, calling the method by passing a null value removes the key/value pair. - - -## Examples - The following example creates a new and adds items. The code also demonstrates overwriting an existing item using the method, and includes a commented block that would throw an . - -> [!NOTE] -> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks DbConnectionStringBuilder.Add/VB/source.vb" id="Snippet1"::: - ]]> diff --git a/xml/System.Data.EntityClient/EntityConnectionStringBuilder.xml b/xml/System.Data.EntityClient/EntityConnectionStringBuilder.xml index dc30eb1f20d..fec11ab1fbc 100644 --- a/xml/System.Data.EntityClient/EntityConnectionStringBuilder.xml +++ b/xml/System.Data.EntityClient/EntityConnectionStringBuilder.xml @@ -115,17 +115,11 @@ The invariant Provider name must be specified in the `connectionString` parameter. Supported providers include the following: - `System.Data.Odbc` - - `System.Data.OleDb` - - `System.Data.OracleClient` - - `System.Data.SqlClient` - - `Microsoft.SqlServerCe.Client` - - ## Examples The following example demonstrates how to use the in conjunction with a . The code sets properties of a `SqlConnectionStringBuilder` to create a connection string that supplies part of the underlying provider connection string. Note that the Provider name cannot be set using the `SqlConnectionStringBuilder` because it is not valid `SqlConnection` connection string syntax. The code creates the connection string by setting `EntityConnectionStringBuilder` properties. It does not use the `connectionString` overload. diff --git a/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml b/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml index 655c55c8a0e..1ffc5b4e4ca 100644 --- a/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml +++ b/xml/System.Data.Odbc/OdbcConnectionStringBuilder.xml @@ -82,8 +82,6 @@ Console.WriteLine(builder.ConnectionString); Driver={SQL Server};Server="MyServer;NewValue=Bad" ``` - - ## Examples The following console application builds connection strings for several ODBC databases. First, the example creates a connection string for a Microsoft Access database. It then creates a connection string for an IBM DB2 database. The example also parses an existing connection string, and demonstrates various ways of manipulating the contents of the connection string. diff --git a/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml b/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml index 49ffe1f162d..329b474dcc4 100644 --- a/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml +++ b/xml/System.Data.OleDb/OleDbConnectionStringBuilder.xml @@ -231,17 +231,6 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Sample.mdb;User ID="Admin;NewVal ## Remarks The method removes all key/value pairs from the , and resets all corresponding properties to their default values. This includes setting the property to 0, and setting the property to an empty string. - - -## Examples - The following example demonstrates the effect of calling the method. This example populates the with some key/value pairs, and then calls the method and shows the results. - -> [!NOTE] -> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OleDbConnectionStringBuilder.Clear/VB/source.vb" id="Snippet1"::: - ]]> Connection String Builders diff --git a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml index 28fb325e03b..a2d039681a5 100644 --- a/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml +++ b/xml/System.Data.OracleClient/OracleConnectionStringBuilder.xml @@ -31,54 +31,45 @@ Provides a simple way to create and manage the contents of connection strings used by the class. - class implements the interface. This means that the class works with Visual Studio .NET designers at design time. When developers use the designer to build strongly typed **DataSets** and strongly typed connections within Visual Studio .NET, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys. - - Developers needing to create connection strings as part of applications can use the 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, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the property for a full list of acceptable synonyms. - - The handles attempts to insert malicious entries. For example, the following code, using the default property (the indexer, in C#) correctly escapes the nested key/value pair. - + class implements the interface. This means that the class works with Visual Studio .NET designers at design time. When developers use the designer to build strongly typed **DataSets** and strongly typed connections within Visual Studio .NET, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys. + + Developers needing to create connection strings as part of applications can use the 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, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the property for a full list of acceptable synonyms. + + The handles attempts to insert malicious entries. For example, the following code, using the default property (the indexer, in C#), correctly escapes the nested key/value pair. + ```vb -Dim builder As New System.Data. _ - OracleClient.OracleConnectionStringBuilder -builder("Data Source") = "OracleDemo" -builder("Integrated Security") = True -builder("User ID") = "Mary;NewValue=Bad" -System.Diagnostics.Debug.WriteLine(builder.ConnectionString) -``` - +Dim builder As New System.Data. _ + OracleClient.OracleConnectionStringBuilder +builder("Data Source") = "OracleDemo;NewValue=Bad" +builder("Integrated Security") = True +builder("User ID") = "Mary;NewValue=Bad" +System.Diagnostics.Debug.WriteLine(builder.ConnectionString) +``` + ```csharp -System.Data.OracleClient.OracleConnectionStringBuilder builder = - new System.Data.OracleClient.OracleConnectionStringBuilder(); -builder["Data Source"] = "OracleDemo"; -builder["integrated Security"] = true; -builder["User ID"] = "Mary;NewValue=Bad"; -System.Diagnostics.Debug.WriteLine(builder.ConnectionString); -``` - - The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes: - -``` -Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" -``` - - - -## Examples - The following console application builds connection strings for an Oracle database. The code uses an 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 language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder/VB/source.vb" id="Snippet1"::: - +System.Data.OracleClient.OracleConnectionStringBuilder builder = + new System.Data.OracleClient.OracleConnectionStringBuilder(); +builder["Data Source"] = "OracleDemo"; +builder["integrated Security"] = true; +builder["User ID"] = "Mary;NewValue=Bad"; +System.Diagnostics.Debug.WriteLine(builder.ConnectionString); +``` + + The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes: + +``` +Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" +``` + +[!INCLUDE[ROPC warning](~/includes/ropc-warning.md)] + ]]> Building Connection Strings @@ -132,22 +123,22 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" The basis for the object's internal connection information. Parsed into name/value pairs. Invalid key names raise a . 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 property of the object is retrieved, the string contains only key/value pairs in which the value is different from the default value for the item. - - - -## Examples - The following example supplies a simple connection string in the object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each items. Also note that the class converts synonyms for the well-known keys so that they are consistent with the well-known names. - + class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the property of the object is retrieved, the string contains only key/value pairs in which the value is different from the default value for the item. + + + +## Examples + The following example supplies a simple connection string in the object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each items. Also note that the class converts synonyms for the well-known keys so that they are consistent with the well-known names. + > [!NOTE] -> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. - +> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Ctor/VB/source.vb" id="Snippet1"::: + ]]> Invalid key name within the connection string. @@ -175,19 +166,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Clears the contents of the instance. - method removes all key/value pairs from the , and resets all corresponding properties. This includes resetting the connection string to an empty string. - - - -## Examples - The following example demonstrates the effect of calling the method. This example populates the with some key/value pairs, and then calls the method and shows the results. - + method removes all key/value pairs from the , and resets all corresponding properties. This includes resetting the connection string to an empty string. + + + +## Examples + The following example demonstrates the effect of calling the method. This example populates the with some key/value pairs, and then calls the method and shows the results. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Clear/VB/source.vb" id="Snippet1"::: + ]]> Building Connection Strings @@ -218,19 +209,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" if the contains an element that has the specified key; otherwise, . - 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 an instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the method. - + 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 an instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the method. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.ContainsKey/VB/source.vb" id="Snippet1"::: + ]]> @@ -268,19 +259,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets the name of the Oracle data source to connect to. The value of the property, or if none has been supplied. - will use the well-known "Data Source" key. If the value passed in is null when you try to set the property, the property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . - - - -## Examples - The following example demonstrates that the class converts synonyms for the "Data Source" connection string key into the well-known key. - + will use the well-known "Data Source" key. If the value passed in is null when you try to set the property, the property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . + + + +## Examples + The following example demonstrates that the class converts synonyms for the "Data Source" connection string key into the well-known key. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.DataSource/VB/source.vb" id="Snippet1"::: + ]]> Building Connection Strings @@ -316,11 +307,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets a value that indicates whether the pooler automatically enlists the connection in the creation thread's current transaction context. The value of the property, or if the property has not been previously set. - Building Connection Strings @@ -381,22 +372,22 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets a 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 a if none has been supplied. - property of the object. - + 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. - +> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.IntegratedSecurity/VB/source.vb" id="Snippet1"::: + ]]> Building Connection Strings @@ -449,34 +440,34 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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 . The following table lists all the possible keys within the connection string, and the default value for each. - -|Key|Property|Default value| -|---------|--------------|-------------------| -|Data Source (or server)||Empty string| -|Persist Security Info (or persistsecurityinfo)||False| -|Integrated Security||False| -|User ID (or user or uid)||Empty string| -|Password||Empty string| -|Enlist||True| -|Pooling||True| -|Min Pool Size||0| -|Max Pool Size||100| -|Omit Oracle Connection Name||False| -|Unicode||False| -|Load Balance Timeout (or connection lifetime)||0| - - - -## Examples - The following code, in a console application, creates a new and adds key/value pairs to its connection string, using the property. - + contains a fixed-size dictionary, trying to add a key that does not exist within the dictionary throws a . The following table lists all the possible keys within the connection string, and the default value for each. + +|Key|Property|Default value| +|---------|--------------|-------------------| +|Data Source (or server)||Empty string| +|Persist Security Info (or persistsecurityinfo)||False| +|Integrated Security||False| +|User ID (or user or uid)||Empty string| +|Password||Empty string| +|Enlist||True| +|Pooling||True| +|Min Pool Size||0| +|Max Pool Size||100| +|Omit Oracle Connection Name||False| +|Unicode||False| +|Load Balance Timeout (or connection lifetime)||0| + + + +## Examples + The following code, in a console application, creates a new and adds key/value pairs to its connection string, using the property. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Item/VB/source.vb" id="Snippet1"::: + ]]> @@ -506,19 +497,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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. - + 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 language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Keys/VB/source.vb" id="Snippet1"::: + ]]> @@ -556,11 +547,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before it is removed. The value of the property, or 0 if none has been supplied. - Building Connection Strings @@ -596,11 +587,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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. - Building Connection Strings @@ -636,11 +627,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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. - Building Connection Strings @@ -677,11 +668,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" if transaction rollbacks are enabled; otherwise . - Building Connection Strings @@ -721,16 +712,16 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets the password for the Oracle account. The value of the property, or if none has been supplied. - property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . - + property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . + ]]> Building Connection Strings @@ -766,11 +757,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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. - Building Connection Strings @@ -806,11 +797,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets a Boolean value that indicates whether the connection will be pooled, or whether each connection will be explicitly opened every time that the connection is requested. The value of the property, or if none has been supplied. - Building Connection Strings @@ -841,41 +832,41 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" if the key existed within the connection string and was removed, if the key did not exist. - method returns a value that indicates its success, it is not necessary to look for the existence of a key before trying to remove the key/value pair from the instance. Because the maintains a fixed-size collection of key/value pairs, calling the method just resets the value of the key/value pair back to its default value. - - Because the collection of keys supported by the is fixed, every item within the collection has a known default value. - - The following table lists the keys, and the value for each when the is first initialized, or after the method has been called: - -|Key|Default value| -|---------|-------------------| -|Data Source|Empty string| -|Persist Security Info|False| -|Integrated Security|False| -|User ID|Empty string| -|Password|Empty string| -|Enlist|True| -|Pooling|True| -|Min Pool Size|0| -|Max Pool Size|100| -|Unicode|False| -|Load Balance Timeout|0| -|Omit Oracle Connection Name|False| - - - -## Examples - The following example converts an existing connection string from using Windows Authentication to using integrated security. The example works by removing the user name and password from the connection string, and then setting the property of the object. - + method returns a value that indicates its success, it is not necessary to look for the existence of a key before trying to remove the key/value pair from the instance. Because the maintains a fixed-size collection of key/value pairs, calling the method just resets the value of the key/value pair back to its default value. + + Because the collection of keys supported by the is fixed, every item within the collection has a known default value. + + The following table lists the keys, and the value for each when the is first initialized, or after the method has been called: + +|Key|Default value| +|---------|-------------------| +|Data Source|Empty string| +|Persist Security Info|False| +|Integrated Security|False| +|User ID|Empty string| +|Password|Empty string| +|Enlist|True| +|Pooling|True| +|Min Pool Size|0| +|Max Pool Size|100| +|Unicode|False| +|Load Balance Timeout|0| +|Omit Oracle Connection Name|False| + + + +## Examples + The following example converts an existing connection string from using Windows Authentication to using integrated security. The example works by removing the user name and password from the connection string, and then setting the property of the object. + > [!NOTE] -> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. - +> This example includes a password to demonstrate how works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Remove/VB/source.vb" id="Snippet1"::: + ]]> @@ -908,11 +899,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" if the contains an entry with the specified key; otherwise, . - method. - + method. + ]]> Building Connection Strings @@ -945,19 +936,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" if was found within the connection string; otherwise, . - method lets developers safely retrieve a value from an without needing to verify that the supplied key name is a valid key name. Because gracefully handles searching for a non-existent key, there is no need to look for the existence of a key before retrieving its value. Calling 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 method. - + method lets developers safely retrieve a value from an without needing to verify that the supplied key name is a valid key name. Because gracefully handles searching for a non-existent key, there is no need to look for the existence of a key before retrieving its value. Calling 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 method. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.TryGetValue/VB/source.vb" id="Snippet1"::: + ]]> Building Connection Strings @@ -993,11 +984,11 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets a Boolean value that indicates if the client supports the Unicode functionality available in later Oracle clients, or if it is non-Unicode aware. The value of the property, or if none has been supplied. - Building Connection Strings @@ -1033,13 +1024,13 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" Gets or sets the user ID to be used when connecting to Oracle. The value of the property, or if none has been supplied. - property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . - + property is reset. If the value has not been set and the developer tries to retrieve the property, the return value is . + ]]> Building Connection Strings @@ -1065,19 +1056,19 @@ Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad" 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. - + 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 language="csharp" source="~/snippets/csharp/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/CS/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks OracleConnectionStringBuilder.Values/VB/source.vb" id="Snippet1"::: + ]]> Building Connection Strings diff --git a/xml/System.Data.SqlClient/SqlCredential.xml b/xml/System.Data.SqlClient/SqlCredential.xml index d9e398ab48c..09da7544ec6 100644 --- a/xml/System.Data.SqlClient/SqlCredential.xml +++ b/xml/System.Data.SqlClient/SqlCredential.xml @@ -26,57 +26,18 @@ - 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. - + 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 user via an object. For information on how a object affects connection pool behavior, see [SQL Server Connection Pooling (ADO.NET)](/dotnet/framework/data/adonet/sql-server-connection-pooling). - - 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(); -``` - + ADO.NET Overview @@ -112,11 +73,11 @@ conn.Open(); 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. - + value is allowed. An attempt to pass a null parameter in the constructor will raise an exception. + ]]> ADO.NET Overview diff --git a/xml/System.Web.Caching/SqlCacheDependency.xml b/xml/System.Web.Caching/SqlCacheDependency.xml index e1ce0122af7..fd1a1dcfeaa 100644 --- a/xml/System.Web.Caching/SqlCacheDependency.xml +++ b/xml/System.Web.Caching/SqlCacheDependency.xml @@ -33,7 +33,7 @@ The following example shows an ASP.NET Web.config file that enables table-based dependencies on a SQL Server database table. -``` +```xml @@ -53,8 +53,6 @@ ``` - - ## Examples The following code example uses the and controls to display a database table. When the page is loaded, the page attempts to create a object. After the object is created, the page adds an item to the `Cache` with a dependency on the object. You should use exception handling similar to that shown here. diff --git a/xml/System.Web.UI.WebControls/Parameter.xml b/xml/System.Web.UI.WebControls/Parameter.xml index 49ceef82742..4f194d85973 100644 --- a/xml/System.Web.UI.WebControls/Parameter.xml +++ b/xml/System.Web.UI.WebControls/Parameter.xml @@ -30,54 +30,54 @@ Provides a mechanism that data source controls use to bind to application variables, user identities and choices, and other data. Serves as the base class for all ASP.NET parameter types. - class represents a parameter in a parameterized SQL query, a filtering expression, or a business object method call that an ASP.NET data source control uses to select, filter, or modify data. objects are contained in a object. objects are evaluated at run time, to bind the values of the variables they represent to whatever method is used by a data source control to interact with data. - - Use classes that derive from with data source and data-bound controls to build Web-based data applications. These parameter classes are used by data source controls to bind specific kinds of values found in Web applications to placeholders in SQL query strings, business object method parameters, and more. The following table lists parameter types that are included in ASP.NET. - -||| -|-|-| -||Binds any public property of a Web server control.| -||Binds a form field.| -||Binds a session-state field.| -||Binds a route URL parameter.| -||Binds a cookie field.| -||Binds a query-string parameter.| -||Binds a profile field.| - - Extend the base class when you want to implement your own custom parameter types. - - objects are very simple: they have a and a property, can be represented declaratively, and can track state across multiple HTTP requests. All parameters support a property, for cases when a parameter is bound to a value, but the value evaluates to `null` at run time. - - When using a collection of objects with a data source control, their order in the collection might matter. For more information on how parameters are used, see [Using Parameters with the SqlDataSource Control](https://learn.microsoft.com/previous-versions/aspnet/z72eefad(v=vs.100)) and [Using Parameters with the ObjectDataSource Control](https://msdn.microsoft.com/library/45fb67ee-9be7-49b7-9421-e242203dafa4). - - - -## Examples - The following example shows how to use the selected value of a control in the W`here` clause of a SQL query. The example uses the class, which derives from the class. - - The element defines the query with a parameter named "@Title" where the value from `DropDownList1` should go. The element specifies that the "@Title" placeholder will be replaced by the value of the property of the `DropDownList1` control. The element is added to the collection of the control. - + class represents a parameter in a parameterized SQL query, a filtering expression, or a business object method call that an ASP.NET data source control uses to select, filter, or modify data. objects are contained in a object. objects are evaluated at run time, to bind the values of the variables they represent to whatever method is used by a data source control to interact with data. + + Use classes that derive from with data source and data-bound controls to build Web-based data applications. These parameter classes are used by data source controls to bind specific kinds of values found in Web applications to placeholders in SQL query strings, business object method parameters, and more. The following table lists parameter types that are included in ASP.NET. + +||| +|-|-| +||Binds any public property of a Web server control.| +||Binds a form field.| +||Binds a session-state field.| +||Binds a route URL parameter.| +||Binds a cookie field.| +||Binds a query-string parameter.| +||Binds a profile field.| + + Extend the base class when you want to implement your own custom parameter types. + + objects are very simple: they have a and a property, can be represented declaratively, and can track state across multiple HTTP requests. All parameters support a property, for cases when a parameter is bound to a value, but the value evaluates to `null` at run time. + + When using a collection of objects with a data source control, their order in the collection might matter. For more information on how parameters are used, see [Using Parameters with the SqlDataSource Control](https://learn.microsoft.com/previous-versions/aspnet/z72eefad(v=vs.100)) and [Using Parameters with the ObjectDataSource Control](https://msdn.microsoft.com/library/45fb67ee-9be7-49b7-9421-e242203dafa4). + + + +## Examples + The following example shows how to use the selected value of a control in the W`here` clause of a SQL query. The example uses the class, which derives from the class. + + The element defines the query with a parameter named "@Title" where the value from `DropDownList1` should go. The element specifies that the "@Title" placeholder will be replaced by the value of the property of the `DropDownList1` control. The element is added to the collection of the control. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_2sql/CS/sql2cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_2sql/VB/sql2vb.aspx" id="Snippet1"::: - - The following example is like the previous one, but uses code instead of markup. When the page loads the first time, the control has no selected value, and the property of the object is used. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_2sql/VB/sql2vb.aspx" id="Snippet1"::: + + The following example is like the previous one, but uses code instead of markup. When the page loads the first time, the control has no selected value, and the property of the object is used. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/CS/param1acs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/VB/param1avb.aspx" id="Snippet1"::: - - The following code shows the code-behind class for the page in the previous example. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/VB/param1avb.aspx" id="Snippet1"::: + + The following code shows the code-behind class for the page in the previous example. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/CS/param1acs.aspx.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/VB/param1avb.aspx.vb" id="Snippet4"::: - - The following code example demonstrates how to extend the class to create a new parameter type that can be used by data source controls and other controls in data-binding scenarios. A data source control can use a `StaticParameter` parameter to bind to the value of any object, typically a string, declared on a Web Forms page. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_3/VB/param1avb.aspx.vb" id="Snippet4"::: + + The following code example demonstrates how to extend the class to create a new parameter type that can be used by data source controls and other controls in data-binding scenarios. A data source control can use a `StaticParameter` parameter to bind to the value of any object, typically a string, declared on a Web Forms page. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet1"::: + ]]> @@ -123,11 +123,11 @@ Initializes a new default instance of the class. - object created with the constructor is initialized with default values for all its properties. The property is initialized to , the property is initialized to , the property is initialized to , and the property is initialized to `null`. - + object created with the constructor is initialized with default values for all its properties. The property is initialized to , the property is initialized to , the property is initialized to , and the property is initialized to `null`. + ]]> @@ -152,19 +152,19 @@ The name of the parameter. Initializes a new instance of the class, using the specified name. - object created with the constructor is initialized with the specified `name` and default values for its other properties. The property is initialized to , the property is initialized to , and the property is initialized to `null`. - - - -## Examples - The following code example demonstrates how to call the constructor from a class that extends the class to initialize the property of the instance. This code example is part of a larger example provided for the class overview. - + object created with the constructor is initialized with the specified `name` and default values for its other properties. The property is initialized to , the property is initialized to , and the property is initialized to `null`. + + + +## Examples + The following code example demonstrates how to call the constructor from a class that extends the class to initialize the property of the instance. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet2"::: + ]]> @@ -190,19 +190,19 @@ A instance from which the current instance is initialized. Initializes a new instance of the class with the values of the original, specified instance. - constructor is a `protected` copy constructor used to clone a instance. The values of the , , , , and properties are all transferred to the new instance. - - - -## Examples - The following code example demonstrates how to call the constructor from a class that extends the class to implement correct object cloning behavior for the class. This code example is part of a larger example provided for the class overview. - + constructor is a `protected` copy constructor used to clone a instance. The values of the , , , , and properties are all transferred to the new instance. + + + +## Examples + The following code example demonstrates how to call the constructor from a class that extends the class to implement correct object cloning behavior for the class. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet4"::: + ]]> @@ -230,11 +230,11 @@ The database type of the parameter. Initializes a new instance of the class, using the specified name and database type. - object created with the constructor is initialized with the specified `name` and `dbType` parameters, and with default values for other properties. The property is initialized to , and the property is initialized to `null`. - + object created with the constructor is initialized with the specified `name` and `dbType` parameters, and with default values for other properties. The property is initialized to , and the property is initialized to `null`. + ]]> @@ -261,19 +261,19 @@ A that describes the type of the parameter. Initializes a new instance of the class, using the specified name and type. - object created with the constructor is initialized with the specified `name` and `type` parameters, and default values for other properties. The property is initialized to , and the property is initialized to `null`. - - - -## Examples - The following code example demonstrates how to call the constructor from a class that extends the class to initialize the and properties of the instance. This code example is part of a larger example provided for the class overview. - + object created with the constructor is initialized with the specified `name` and `type` parameters, and default values for other properties. The property is initialized to , and the property is initialized to `null`. + + + +## Examples + The following code example demonstrates how to call the constructor from a class that extends the class to initialize the and properties of the instance. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet3"::: + ]]> @@ -304,11 +304,11 @@ The default value for the instance, if the is bound to a value that is not yet initialized when is called. Initializes a new instance of the class, using the specified name, the specified database type, and the specified value for its property. - property of the instance is initialized to . - + property of the instance is initialized to . + ]]> @@ -337,19 +337,11 @@ A string that serves as a default value for the parameter, if the is bound to a value that is not yet initialized when is called. Initializes a new instance of the class, using the specified name, the specified type, and the specified string for its property. - object created with the constructor is initialized with the specified `name` parameter and `type` parameter, and assigned a property value. The property is initialized to . - - - -## Examples - The following code example demonstrates how to use the constructor to add update parameter objects to the collection of an control before calling the method. - - :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx" id="Snippet2"::: - + object created with the constructor is initialized with the specified `name` parameter and `type` parameter, and assigned a property value. The property is initialized to . + ]]> @@ -378,21 +370,21 @@ Returns a duplicate of the current instance. A that is an exact duplicate of the current one. - method calls the copy constructor to initialize a new instance of the class with the values of the current instance. - - If you extend the class, you can override the method to include any state that should be copied to a new instance of your derived class. - - - -## Examples - The following code example demonstrates how to call the constructor from a class that extends the class to implement correct object cloning behavior for the class. This code example is part of a larger example provided for the class. - + method calls the copy constructor to initialize a new instance of the class with the values of the current instance. + + If you extend the class, you can override the method to include any state that should be copied to a new instance of your derived class. + + + +## Examples + The following code example demonstrates how to call the constructor from a class that extends the class to implement correct object cloning behavior for the class. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet4"::: + ]]> @@ -422,11 +414,11 @@ Converts a value to an equivalent value. A value that is equivalent to the specified value. - instance if no equivalent for the value is found. Database types without equivalent types include , , and . - + instance if no equivalent for the value is found. Database types without equivalent types include , , and . + ]]> @@ -458,11 +450,11 @@ if the value that the is bound to should be converted to when it is ; otherwise, . The default value is . - property of the parameter is changed, the method is called. - + property of the parameter is changed, the method is called. + ]]> @@ -491,11 +483,11 @@ Converts a value to an equivalent value. A value that is equivalent to the specified value. - instance if no equivalent is found. Types without equivalent database types include and . - + instance if no equivalent is found. Types without equivalent database types include and . + ]]> @@ -526,13 +518,13 @@ Gets or sets the database type of the parameter. The database type of the instance. The default value is . - property, the method is called. - + property, the method is called. + ]]> An attempt was made to set this property to a value that is not in the enumeration. @@ -564,23 +556,23 @@ Specifies a default value for the parameter, should the value that the parameter is bound to be uninitialized when the method is called. A string that serves as a default value for the when the value it is bound to cannot be resolved or is uninitialized. - property is used in scenarios where the parameter is bound to a value, but the value is `null` or cannot be resolved when the object is evaluated. - - If the property of the parameter is changed, the method is called. - - - -## Examples - The following code example demonstrates how to retrieve a single data record using an control and display it in a control. The control retrieves a specific employee record by calling the `GetEmployee` method of the `EmployeeLogic` class. The `GetEmployee` method requires an employee ID parameter. The control uses a object in its collection to pass an ID to the `GetEmployee` method in this example. - - To view the example implementation of the `EmployeeLogic` class and the `GetEmployee` method, see the class overview. - + property is used in scenarios where the parameter is bound to a value, but the value is `null` or cannot be resolved when the object is evaluated. + + If the property of the parameter is changed, the method is called. + + + +## Examples + The following code example demonstrates how to retrieve a single data record using an control and display it in a control. The control retrieves a specific employee record by calling the `GetEmployee` method of the `EmployeeLogic` class. The `GetEmployee` method requires an employee ID parameter. The control uses a object in its collection to pass an ID to the `GetEmployee` method in this example. + + To view the example implementation of the `EmployeeLogic` class and the `GetEmployee` method, see the class overview. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_3/CS/objds3cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_3/VB/objds3vb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_3/VB/objds3vb.aspx" id="Snippet1"::: + ]]> @@ -611,23 +603,23 @@ Indicates whether the object is used to bind a value to a control, or the control can be used to change the value. One of the values. is set to by default. - property is currently not used by the class and is reserved for future use. - - The property describes the direction of the flow of data between the value that a instance is bound to and the object itself. The default value for the property, , describes the most common scenario where the flow of data is always in one direction: from the value to which the object is bound to the object. Any changes made to the underlying value are reflected by the object, but any changes to the object are not reflected by the underlying data. You can set the property to or when working with output parameters, or when working with a return value from a stored procedure. - - If the property of the parameter is changed, the method is called. - - - -## Examples - The following code example demonstrates how to set the , , and properties of objects when using them as output parameters and return value parameters with a stored procedure. This code example is part of a larger example provided for the class overview. - + property is currently not used by the class and is reserved for future use. + + The property describes the direction of the flow of data between the value that a instance is bound to and the object itself. The default value for the property, , describes the most common scenario where the flow of data is always in one direction: from the value to which the object is bound to the object. Any changes made to the underlying value are reflected by the object, but any changes to the object are not reflected by the underlying data. You can set the property to or when working with output parameters, or when working with a return value from a stored procedure. + + If the property of the parameter is changed, the method is called. + + + +## Examples + The following code example demonstrates how to set the , , and properties of objects when using them as output parameters and return value parameters with a stored procedure. This code example is part of a larger example provided for the class overview. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/CS/sql21cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: + ]]> @@ -662,19 +654,19 @@ Updates and returns the value of the object. An that represents the updated and current value of the parameter. - method is to return `null` in all cases. Classes that derive from the class override the method to return an updated parameter value. For example, the object returns the value of the control that it is bound to, while the object retrieves the current name/value pair from the object. - - - -## Examples - The following code example demonstrates how to override the method to return the correct value in a class that is derived from the class. This code example is part of a larger example provided for the class overview. - + method is to return `null` in all cases. Classes that derive from the class override the method to return an updated parameter value. For example, the object returns the value of the control that it is bound to, while the object retrieves the current name/value pair from the object. + + + +## Examples + The following code example demonstrates how to override the method to return the correct value in a class that is derived from the class. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet6"::: + ]]> @@ -700,11 +692,11 @@ Gets the value that is equivalent to the CLR type of the current instance. The value that is equivalent to the CLR type of the current instance. - property must not already have been set, or must be set to . This method is intended for use only when the CLR type is set but the property is not. - + property must not already have been set, or must be set to . This method is intended for use only when the CLR type is set but the property is not. + ]]> The property is already set to a value other than . @@ -766,13 +758,13 @@ An that represents the state to restore. Restores the data source view's previously saved view state. - object from a previous page request that was saved by the method. - + object from a previous page request that was saved by the method. + ]]> @@ -807,25 +799,25 @@ Gets or sets the name of the parameter. The name of the parameter. The default value is . - objects are not required to have a name; however, data source controls might use the parameter name to match a object in a collection with a parameter in a SQL query or business method signature. For example, the control can use the name of the object to match a placeholder in a parameterized SQL query. Similarly, the control can use the name of a object in the collection to match a placeholder in the property. In some cases, the name is not used and the order in which the object is added to a collection is more important. For more information, see [Using Parameters with the SqlDataSource Control](https://learn.microsoft.com/previous-versions/aspnet/z72eefad(v=vs.100)) and [Using Parameters with the ObjectDataSource Control](https://msdn.microsoft.com/library/45fb67ee-9be7-49b7-9421-e242203dafa4). - - If the name of the parameter is changed, the method is called. - - - -## Examples - The following code example demonstrates how to display filtered data using an control to retrieve data from a middle-tier business object and a control to display the results. The code example consists of a control, a control, the control, and a Submit button. By default, the control is populated with the name of one of the `Northwind` employees. The control displays information about the employee identified by the name in the control. To retrieve data on another employee, enter the full name of the employee in the control and click the button. - - The property specifies an expression used to filter the data retrieved by the property. It uses parameter placeholders that are evaluated to the parameters contained in the collection. In this example, the parameter placeholder is bounded by single quotation marks because the type of the parameter is a string type that might contain spaces. If the type of the parameter is a numeric or date type, bounding quotation marks are not needed. - - This code example is part of a larger example provided for the property of the class. - + objects are not required to have a name; however, data source controls might use the parameter name to match a object in a collection with a parameter in a SQL query or business method signature. For example, the control can use the name of the object to match a placeholder in a parameterized SQL query. Similarly, the control can use the name of a object in the collection to match a placeholder in the property. In some cases, the name is not used and the order in which the object is added to a collection is more important. For more information, see [Using Parameters with the SqlDataSource Control](https://learn.microsoft.com/previous-versions/aspnet/z72eefad(v=vs.100)) and [Using Parameters with the ObjectDataSource Control](https://msdn.microsoft.com/library/45fb67ee-9be7-49b7-9421-e242203dafa4). + + If the name of the parameter is changed, the method is called. + + + +## Examples + The following code example demonstrates how to display filtered data using an control to retrieve data from a middle-tier business object and a control to display the results. The code example consists of a control, a control, the control, and a Submit button. By default, the control is populated with the name of one of the `Northwind` employees. The control displays information about the employee identified by the name in the control. To retrieve data on another employee, enter the full name of the employee in the control and click the button. + + The property specifies an expression used to filter the data retrieved by the property. It uses parameter placeholders that are evaluated to the parameters contained in the collection. In this example, the parameter placeholder is bounded by single quotation marks because the type of the parameter is a string type that might contain spaces. If the type of the parameter is a numeric or date type, bounding quotation marks are not needed. + + This code example is part of a larger example provided for the property of the class. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_9/CS/objds9cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_9/VB/objds9vb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_9/VB/objds9vb.aspx" id="Snippet1"::: + ]]> @@ -851,25 +843,25 @@ Calls the method of the collection that contains the object. - object is not contained by a collection, calling the method has no effect. If the object is contained by a collection, raises the event of the collection. - - If the collection is contained by a data source control, the event raises the data source control's event, causing any data-bound controls to rebind. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - - - -## Examples - The following code example demonstrates how to call the method to raise the event when the state of a parameter changes. This code example is part of a larger example provided for the class overview. - + object is not contained by a collection, calling the method has no effect. If the object is contained by a collection, raises the event of the collection. + + If the collection is contained by a data source control, the event raises the data source control's event, causing any data-bound controls to rebind. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + + + +## Examples + The following code example demonstrates how to call the method to raise the event when the state of a parameter changes. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet7"::: + ]]> @@ -899,15 +891,15 @@ Saves the changes to the object's view state since the time the page was posted back to the server. The that contains the changes to the view state. If there is no view state associated with the object, this method returns . - property, which is an instance of the class. This property's value is then persisted to a string object after the save state stage of the server control life cycle. - - When view state is saved, this string object is returned to the client as a variable that is stored in an HTML `hidden` element. When you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's property. - + property, which is an instance of the class. This property's value is then persisted to a string object after the save state stage of the server control life cycle. + + When view state is saved, this string object is returned to the client as a variable that is stored in an HTML `hidden` element. When you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's property. + ]]> @@ -936,11 +928,11 @@ Marks the object so its state will be recorded in view state. - method is called directly by the method, to mark the object so that its state is recorded in view state. - + method is called directly by the method, to mark the object so that its state is recorded in view state. + ]]> @@ -972,11 +964,11 @@ Gets or sets the size of the parameter. The size of the parameter expressed as an integer. - is changed, the method is called. - + is changed, the method is called. + ]]> @@ -1012,13 +1004,13 @@ Returns a duplicate of the current instance. A that is a copy of the current object. - method calls the constructor to initialize a new instance of the class with the values of the current instance. - - If you extend the class, you can override the method to include any state that should be copied to a new instance of your derived class. - + method calls the constructor to initialize a new instance of the class with the values of the current instance. + + If you extend the class, you can override the method to include any state that should be copied to a new instance of your derived class. + ]]> @@ -1100,13 +1092,13 @@ This member is an explicit interface member implementation. It can be used only An that represents the state to restore. Restores the data source view's previously saved view state. - object from a previous page request that was saved by the method. - - This method is used primarily by control developers. You can override this method to control how a custom server control restores its view state. - + object from a previous page request that was saved by the method. + + This method is used primarily by control developers. You can override this method to control how a custom server control restores its view state. + ]]> @@ -1145,15 +1137,15 @@ This member is an explicit interface member implementation. It can be used only Saves the changes to the object's view state since the time the page was posted back to the server. The that contains the changes to the object's view state. If there is no view state associated with the object, this method returns . - property, which is an instance of the class. This property's value is then persisted to a string object after the save state stage of the server control life cycle. - - When view state is saved, this string object is returned to the client as a variable that is stored in an HTML `hidden` element. When you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's property. - + property, which is an instance of the class. This property's value is then persisted to a string object after the save state stage of the server control life cycle. + + When view state is saved, this string object is returned to the client as a variable that is stored in an HTML `hidden` element. When you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's property. + ]]> @@ -1228,19 +1220,19 @@ This member is an explicit interface member implementation. It can be used only Converts the value of this instance to its equivalent string representation. A string representation of the value of this instance. - method returns the property of the object. If the object has no name, returns . - - - -## Examples - The following code example demonstrates how to access various properties of a object, including its and properties. - + method returns the property of the object. If the object has no name, returns . + + + +## Examples + The following code example demonstrates how to access various properties of a object, including its and properties. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter.ToString_1/CS/parametertostringcs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter.ToString_1/VB/parametertostringvb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter.ToString_1/VB/parametertostringvb.aspx" id="Snippet1"::: + ]]> @@ -1296,21 +1288,21 @@ This member is an explicit interface member implementation. It can be used only Gets or sets the type of the parameter. The type of the . The default value is . - method is called. - - - -## Examples - The following code example demonstrates how to set the , , and properties of objects when using them as output parameters and return value parameters with a stored procedure. This code example is part of a larger example provided for the class overview. - + method is called. + + + +## Examples + The following code example demonstrates how to set the , , and properties of objects when using them as output parameters and return value parameters with a stored procedure. This code example is part of a larger example provided for the class overview. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/CS/sql21cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: + ]]> The parameter type is not one of the values. @@ -1349,21 +1341,21 @@ This member is an explicit interface member implementation. It can be used only Gets a dictionary of state information that allows you to save and restore the view state of a object across multiple requests for the same page. An instance of that contains the object's view-state information. - class, to store the property values. The values are then passed as a variable to an HTML `hidden` input element when subsequent requests are processed. View state is enabled for all server controls by default. - - For more information about dictionaries and how to use them, see [Collections and Data Structures](/dotnet/standard/collections/). - - - -## Examples - The following code example demonstrates how to use the view-state object to store parameter object state in a class that extends the class. This code example is part of a larger example provided for the class overview. - + class, to store the property values. The values are then passed as a variable to an HTML `hidden` input element when subsequent requests are processed. View state is enabled for all server controls by default. + + For more information about dictionaries and how to use them, see [Collections and Data Structures](/dotnet/standard/collections/). + + + +## Examples + The following code example demonstrates how to use the view-state object to store parameter object state in a class that extends the class. This code example is part of a larger example provided for the class overview. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/CS/staticparameter.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.Parameter_2/VB/staticparameter.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Web.UI.WebControls/QueryStringParameter.xml b/xml/System.Web.UI.WebControls/QueryStringParameter.xml index b4f38c434b1..bd6eceb90c8 100644 --- a/xml/System.Web.UI.WebControls/QueryStringParameter.xml +++ b/xml/System.Web.UI.WebControls/QueryStringParameter.xml @@ -23,31 +23,24 @@ Binds the value of an HTTP request query-string field to a parameter object. - class to bind the value of a field that is passed as part of an HTTP request query string to a parameter that is used in a parameterized query or command. The field is retrieved from the collection. - - Controls that bind data to the parameter might throw an exception if a object is referenced, but no corresponding query-string name/value pair is passed. Similarly, they might display no data if the query-string field name is passed without a corresponding value. To avoid these situations, set the property where appropriate. - - The class provides the property, which identifies the name of the query string value to bind to. It also provides the properties that are inherited from the class. - + class to bind the value of a field that is passed as part of an HTTP request query string to a parameter that is used in a parameterized query or command. The field is retrieved from the collection. + + Controls that bind data to the parameter might throw an exception if a object is referenced, but no corresponding query-string name/value pair is passed. Similarly, they might display no data if the query-string field name is passed without a corresponding value. To avoid these situations, set the property where appropriate. + + The class provides the property, which identifies the name of the query string value to bind to. It also provides the properties that are inherited from the class. + > [!IMPORTANT] -> The class does not validate the value that is passed; it provides the raw value. However, you can validate the value of a object in a data source control. To do so, handle the `Selecting`, `Updating`, `Inserting`, or `Deleting` event of the data source control and check the parameter value in the event handler. If the value of the parameter does not pass the validation tests, you can cancel the data operation by setting the property of the associated class to `true`. - - - -## Examples - The following example shows how to create a object to use as a filter when you display data in a control. You add the object to the control's collection. The parameter object binds the value of the query-string field named `country` to its string. Because no property is specified for the parameter, if no field named `country` is passed with the query string, the control throws a exception. If a field named `country` is passed but has no value, the control displays no data. - +> The class does not validate the value that is passed; it provides the raw value. However, you can validate the value of a object in a data source control. To do so, handle the `Selecting`, `Updating`, `Inserting`, or `Deleting` event of the data source control and check the parameter value in the event handler. If the value of the parameter does not pass the validation tests, you can cancel the data operation by setting the property of the associated class to `true`. + +## Examples + The following example shows how to create a object to use as a filter when you display data in a control. You add the object to the control's collection. The parameter object binds the value of the query-string field named `country` to its string. Because no property is specified for the parameter, if no field named `country` is passed with the query string, the control throws a exception. If a field named `country` is passed but has no value, the control displays no data. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_4/CS/qsp4cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_4/VB/qsp4vb.aspx" id="Snippet1"::: - - The following example shows how to create a object to display data from an Access database by using a parameterized SQL query. The object retrieves records that are then displayed in a control. The control is also editable, and lets users update the status of orders in the Northwind Traders Orders table. - - :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_4/VB/qsp4vb.aspx" id="Snippet1"::: + ]]> @@ -89,34 +82,34 @@ Initializes a new unnamed instance of the class. - object that is created by using the constructor is initialized with default values for all its properties. The properties are initialized as follows: - -- is initialized to an empty string (""). - -- is initialized to an empty string (""). - -- is initialized to . - -- is initialized to . - -- is initialized to `null`. - - - -## Examples - The following example shows how to use the constructor to create a new parameter and add it to the collection of an control. - + object that is created by using the constructor is initialized with default values for all its properties. The properties are initialized as follows: + +- is initialized to an empty string (""). + +- is initialized to an empty string (""). + +- is initialized to . + +- is initialized to . + +- is initialized to `null`. + + + +## Examples + The following example shows how to use the constructor to create a new parameter and add it to the collection of an control. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/CS/querystrparam1cs.aspx.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx.vb" id="Snippet2"::: - - The object is added to the control and is declared in an ASP.NET Web page. The control uses the control to bind and display data whenever the page is requested with a query string that contains a field that is named `empId` and that has a corresponding value. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx.vb" id="Snippet2"::: + + The object is added to the control and is declared in an ASP.NET Web page. The control uses the control to bind and display data whenever the page is requested with a query string that contains a field that is named `empId` and that has a corresponding value. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/CS/querystrparam1cs.aspx" id="Snippet3"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx" id="Snippet3"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx" id="Snippet3"::: + ]]> @@ -141,11 +134,11 @@ A instance from which the current instance is initialized. Initializes a new instance of the class, using the values of the instance that is specified by the parameter. - constructor is a protected copy constructor that is used to clone a instance. The values of the , , and properties are transferred to the new instance. - + constructor is a protected copy constructor that is used to clone a instance. The values of the , , and properties are transferred to the new instance. + ]]> @@ -173,19 +166,19 @@ The name of the query-string field that the parameter object is bound to. The default is an empty string (""). Initializes a new named instance of the class, using the specified string to identify which query-string field to bind to. - object that is created by using the constructor is initialized with the specified parameter name that identifies the query-string field that the parameter binds to. The and properties are initialized with default values. - - - -## Examples - The following example shows how to create two objects by using the constructor and add them to an control's collection. A control displays data if the `employee` and `country` query-string fields are passed with the request and if they have valid values. - + object that is created by using the constructor is initialized with the specified parameter name that identifies the query-string field that the parameter binds to. The and properties are initialized with default values. + + + +## Examples + The following example shows how to create two objects by using the constructor and add them to an control's collection. A control displays data if the `employee` and `country` query-string fields are passed with the request and if they have valid values. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_2/CS/qsp2cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_2/VB/qsp2vb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_2/VB/qsp2vb.aspx" id="Snippet1"::: + ]]> @@ -242,19 +235,19 @@ The name of the query-string field that the parameter object is bound to. The default is an empty string (""). Initializes a new named and strongly typed instance of the class, using the specified string to identify which query-string field to bind to. - object that is created by using the constructor is initialized with the specified parameter name, the parameter type, and a string that identifies the query-string field that the parameter binds to. The and properties are initialized with default values. - - - -## Examples - The following example shows how to create a object by using the constructor and add it to an control's collection. A control displays data if the `employee` and `country` query-string fields are passed with the request and if they have valid values. - + object that is created by using the constructor is initialized with the specified parameter name, the parameter type, and a string that identifies the query-string field that the parameter binds to. The and properties are initialized with default values. + + + +## Examples + The following example shows how to create a object by using the constructor and add it to an control's collection. A control displays data if the `employee` and `country` query-string fields are passed with the request and if they have valid values. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_3/CS/qsp3cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_3/VB/qsp3vb.aspx" id="Snippet1"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_3/VB/qsp3vb.aspx" id="Snippet1"::: + ]]> @@ -282,11 +275,11 @@ Returns a duplicate of the current instance. A duplicate of the current instance. - method calls the constructor to initialize a new instance of the class by using the values of the current instance. - + method calls the constructor to initialize a new instance of the class by using the values of the current instance. + ]]> @@ -318,19 +311,19 @@ The current instance of the request. - A Web server control that is associated with the ASP.NET Web page where the object is used. - + A Web server control that is associated with the ASP.NET Web page where the object is used. + **Note** This parameter is not used. Updates and returns the value of the object. An object that represents the current value of the parameter. If the context or the request is , the method returns . - object tries to bind to the query-string field every time that the method is called. - - The `context` parameter is used by the method to retrieve the value of the specified query-string field from the query string. The `control` parameter is ignored. - + object tries to bind to the query-string field every time that the method is called. + + The `context` parameter is used by the method to retrieve the value of the specified query-string field from the query string. The `control` parameter is ignored. + ]]> @@ -362,24 +355,24 @@ Gets or sets the name of the query-string field that the parameter binds to. The name of the query-string field that the parameter binds to. - property identifies a name/value pair that is passed with the query string. The property identifies the name of the pair, whereas the property binds to its corresponding value at run time. If the expected query-string name/value pair is not passed to the page with the query string, the method then tries to bind the parameter to the value of the property. If the property is not set, the method fails to bind the parameter to a value. - - - -## Examples - The following example shows how to use a object together with a control to display data in a control. The property is set to the name of the expected query-string field, and the parameter is added to the collection. A property is provided in case the name/value pair is not passed with the query string. - + property identifies a name/value pair that is passed with the query string. The property identifies the name of the pair, whereas the property binds to its corresponding value at run time. If the expected query-string name/value pair is not passed to the page with the query string, the method then tries to bind the parameter to the value of the property. If the property is not set, the method fails to bind the parameter to a value. + + + +## Examples + The following example shows how to use a object together with a control to display data in a control. The property is set to the name of the expected query-string field, and the parameter is added to the collection. A property is provided in case the name/value pair is not passed with the query string. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/CS/querystrparam1cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx" id="Snippet1"::: - - The following example shows how to use a object together with a control to display data in a control. The object is added to the collection, together with other parameter objects that are used for the output parameter and return value. To retrieve data, handle the values that are returned from the stored procedure. This code example is part of a larger example that is provided for the class. - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.QueryStringParameter_1/VB/querystrparam1vb.aspx" id="Snippet1"::: + + The following example shows how to use a object together with a control to display data in a control. The object is added to the collection, together with other parameter objects that are used for the output parameter and return value. To retrieve data, handle the values that are returned from the stored procedure. This code example is part of a larger example that is provided for the class. + :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/CS/sql21cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: - + :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSourceStatusEventArgs_1/VB/sql21vb.aspx" id="Snippet2"::: + ]]> @@ -410,11 +403,11 @@ if the value of the query parameter is being validated; otherwise, . - is set to `true`, and the property is set to `false`, the query string parameter will not be validated. However, if the page property is set to `true`, and the property is set to `true`, the query string parameter will be validated. If the page property is set to `false`, the query string parameter will be validated regardless of whether the property is set to `true` or `false`. - + is set to `true`, and the property is set to `false`, the query string parameter will not be validated. However, if the page property is set to `true`, and the property is set to `true`, the query string parameter will be validated. If the page property is set to `false`, the query string parameter will be validated regardless of whether the property is set to `true` or `false`. + ]]> diff --git a/xml/System.Web.UI.WebControls/SqlDataSource.xml b/xml/System.Web.UI.WebControls/SqlDataSource.xml index bc28b3884dd..94e478cc838 100644 --- a/xml/System.Web.UI.WebControls/SqlDataSource.xml +++ b/xml/System.Web.UI.WebControls/SqlDataSource.xml @@ -1040,29 +1040,12 @@ This section contains four code examples: > [!IMPORTANT] > For information about storing a connection string, see [How To: Secure Connection Strings when Using Data Source Controls](https://learn.microsoft.com/previous-versions/aspnet/ms178372(v=vs.100)). - - ## Examples - This section contains two code examples. The first code example demonstrates how to set the property to connect to a Microsoft SQL Server database and display the results of the property in a control. The second code example demonstrates a more complex scenario, where a control is used to display and update data in a password-protected Microsoft Access database. In each case, the `connectionStrings` element of the Web.config file is shown first, followed by the ASP.NET page that contains the control. - - The following code example demonstrates how to set the property to connect to a SQL Server database and display the results of the property in a control. - +The following code example demonstrates how to set the property to connect to a SQL Server database and display the results of the property in a control. :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_3sql/CS/sql3cs.aspx" id="Snippet1"::: :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_3sql/VB/sql3vb.aspx" id="Snippet1"::: - - The following code example demonstrates a more complex scenario than the preceding code example, where a control is used to display and update data in a password-protected Access database. Because the is used with Access, the property is set to the provider, and the property is set to an appropriate connection string for a UNC-shared Access database. A control displays orders with shipment dates. You can update an order by checking the appropriate check box, and then clicking the **Update** button. - -> [!IMPORTANT] -> This example includes a password in plain text only for illustration purposes. In a production application, connection strings that include passwords should be encrypted. For more information, see [Protecting Connection Information](/dotnet/framework/data/adonet/protecting-connection-information). - - :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx" id="Snippet1"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx" id="Snippet1"::: - - :::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/CS/sql22cs.aspx" id="Snippet2"::: - :::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.SqlDataSource_22sql/VB/sql22vb.aspx" id="Snippet2"::: - ]]>