- Код: Выделить всё
Public Class Form1
'
Private oCommand As OleDbCommand
Private oConnection As OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\GTW\Datbank\datanorm4.mdb")
Private oDataAdapter As OleDbDataAdapter
Private oDataSet As Data.DataSet
Private oCommandBuilder As OleDbCommandBuilder
'
Private Sub butLaden_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butLaden.Click
oCommand = New OleDbCommand("SELECT * FROM Artikel", oConnection)
oDataAdapter = New OleDbDataAdapter(oCommand)
oCommandBuilder = New OleDbCommandBuilder(oDataAdapter)
oDataSet = New Data.DataSet("Allgemein")
Dim oDataTable As New DataTable("Artikel")
oDataSet.Tables.Add(oDataTable)
If oConnection.State = ConnectionState.Closed Then oConnection.Open()
oDataAdapter.Fill(oDataSet.Tables("Artikel"))
dgvArtikel.DataSource = oDataSet.Tables("Artikel")
End Sub
'
Private Sub butDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butDel.Click
Dim oRow As DataRow = (oDataSet.Tables("Artikel").Rows.Item(0))
oDataSet.Tables("Artikel").Rows.Remove(oRow)
oRow = oDataSet.Tables("Artikel").Rows.Item(1)
oDataSet.Tables("Artikel").Rows.Remove(oRow)
oRow = oDataSet.Tables("Artikel").Rows.Item(2)
oDataSet.Tables("Artikel").Rows.Remove(oRow)
'
Debug.Print("Dataset: " & oDataSet.Tables("Artikel").Rows.Count)
Debug.Print("Datagrid: " & dgvArtikel.RowCount)
'
oDataAdapter.Update(oDataSet, "Artikel")
oConnection.Close()
End Sub
End Class
dgvArtikel это DataGridView