CommandBuilder System.Data.SqlClient








Me.cnAdoSbs = New System.Data.SqlClient.SqlConnection

Me.SqlSelectCommand2 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand

Me.daCategories = New System.Data.SqlClient.SqlDataAdapter

Me.SqlSelectCommand2 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand2 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand2 = New System.Data.SqlClient.SqlCommand
Me.SqlDeleteCommand2 = New System.Data.SqlClient.SqlCommand

Me.daProducts = New System.Data.SqlClient.SqlDataAdapter



'SqlSelectCommand1

'

Me.SqlSelectCommand1.CommandText = "SELECT Categories.*" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "FROM Categories"
Me.SqlSelectCommand1.Connection = Me.cnAdoSbs
'

'cnAdoSbs

'

Me.cnAdoSbs.ConnectionString = "Data Source=(local);Initial Catalog=AdoStepByStep;Integrated Security=True"
Me.cnAdoSbs.FireInfoMessageEventOnUserErrors = False
'

'SqlInsertCommand1

'

Me.SqlInsertCommand1.CommandText = resources.GetString("SqlInsertCommand1.CommandText")
Me.SqlInsertCommand1.Connection = Me.cnAdoSbs
Me.SqlInsertCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@CategoryID", System.Data.SqlDbType.Int, 0, "CategoryID"), New System.Data.SqlClient.SqlParameter("@CategoryName", System.Data.SqlDbType.NVarChar, 0, "CategoryName"), New System.Data.SqlClient.SqlParameter("@Description", System.Data.SqlDbType.NText, 0, "Description"), New System.Data.SqlClient.SqlParameter("@Current", System.Data.SqlDbType.Bit, 0, "Current")})
'

'SqlUpdateCommand1

'

Me.SqlUpdateCommand1.CommandText = resources.GetString("SqlUpdateCommand1.CommandText")
Me.SqlUpdateCommand1.Connection = Me.cnAdoSbs
Me.SqlUpdateCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@CategoryID", System.Data.SqlDbType.Int, 0, "CategoryID"), New System.Data.SqlClient.SqlParameter("@CategoryName", System.Data.SqlDbType.NVarChar, 0, "CategoryName"), New System.Data.SqlClient.SqlParameter("@Description", System.Data.SqlDbType.NText, 0, "Description"), New System.Data.SqlClient.SqlParameter("@Current", System.Data.SqlDbType.Bit, 0, "Current"), New System.Data.SqlClient.SqlParameter("@Original_CategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CategoryID", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_CategoryName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CategoryName", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_Current", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Current", System.Data.DataRowVersion.Original, Nothing)})
'

'SqlDeleteCommand1

'

Me.SqlDeleteCommand1.CommandText = "DELETE FROM [Categories] WHERE (([CategoryID] = @Original_CategoryID) AND ([Categ" & _
"oryName] = @Original_CategoryName) AND ([Current] = @Original_Current))"
Me.SqlDeleteCommand1.Connection = Me.cnAdoSbs
Me.SqlDeleteCommand1.Parameters.AddRange(New System.Data.SqlClient.SqlParameter() {New System.Data.SqlClient.SqlParameter("@Original_CategoryID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CategoryID", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_CategoryName", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CategoryName", System.Data.DataRowVersion.Original, Nothing), New System.Data.SqlClient.SqlParameter("@Original_Current", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Current", System.Data.DataRowVersion.Original, Nothing)})
'

'daCategories

'

Me.daCategories.DeleteCommand = Me.SqlDeleteCommand1
Me.daCategories.InsertCommand = Me.SqlInsertCommand1
Me.daCategories.SelectCommand = Me.SqlSelectCommand1
Me.daCategories.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Categories", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CategoryID", "CategoryID"), New System.Data.Common.DataColumnMapping("CategoryName", "CategoryName"), New System.Data.Common.DataColumnMapping("Description", "Description"), New System.Data.Common.DataColumnMapping("Current", "Current")})})
Me.daCategories.UpdateCommand = Me.SqlUpdateCommand1
'

'SqlSelectCommand2

'

Me.SqlSelectCommand2.CommandText = "SELECT Products.*" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "FROM Products"
Me.SqlSelectCommand2.Connection = Me.cnAdoSbs
'

'daProducts

'

Me.daProducts.DeleteCommand = Me.SqlDeleteCommand2
Me.daProducts.InsertCommand = Me.SqlInsertCommand2
Me.daProducts.SelectCommand = Me.SqlSelectCommand2
Me.daProducts.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Products", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ProductID", "ProductID"), New System.Data.Common.DataColumnMapping("ProductName", "ProductName"), New System.Data.Common.DataColumnMapping("SupplierID", "SupplierID"), New System.Data.Common.DataColumnMapping("CategoryID", "CategoryID"), New System.Data.Common.DataColumnMapping("QuantityPerUnit", "QuantityPerUnit"), New System.Data.Common.DataColumnMapping("UnitPrice", "UnitPrice"), New System.Data.Common.DataColumnMapping("UnitsInStock", "UnitsInStock"), New System.Data.Common.DataColumnMapping("UnitsOnOrder", "UnitsOnOrder"), New System.Data.Common.DataColumnMapping("ReorderLevel", "ReorderLevel"), New System.Data.Common.DataColumnMapping("Discontinued", "Discontinued")})})
Me.daProducts.UpdateCommand = Me.SqlUpdateCommand2
'

'DataAdapters










( commandbuildersystemdatasqlclient.html )- by Paolo Puglisi - Modifica del 17/12/2023