Private cbEmployees As SqlCommandBuilder
Private Sub btnLoad_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnLoad.Click
dsEmployeeInfo = New DataSet()
LoadCommandBuilder()
' Конфигурирование объекта-сетки DataGrid.
Me.grdDataGrid.PreferredColumnWidth = 110
Me.grdDataGrid.AllowSorting = True
' Вставка данных в объект DataSet.
daEmployees.Fill(dsEmployeeInfo, "Employees")
' Присвоение объекта DataSet объекту DataGrid.
Me.grdDataGrid.DataSource = _
dsEmployeeInfo.Tables("Employees")
Me.btnUpdate.Enabled = True
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnUpdate.Click
daEmployees.Update(dsEmployeeInfo, "Employees")
End Sub
Private Sub LoadCommandBuilder()
Dim param As SqlParameter
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
' Создание нового объекта DataAdapter.
Dim SQL As String SQL = "Select FirstName, LastName, Department ID, Salary, _
ID from tblEmployee"
daEmployees = New SqlDataAdapter(SQL, conn)
' Создание команды с помощью SqlCommandBuilder.
cbEmployees = New SqlCommandBuilder(daEmployees)