Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Imports System.Data.OleDb

Public Class Form1
Dim con As New OleDbConnection

Private Property TableAdapter As Object

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database21DataSet.Table1' table. You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.Database21DataSet.Table1)
Try
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=..\Database21.mdb"
con.Open()
showMyRecords()
con.Close()

Catch ex As Exception

End Try
End Sub
Public Sub showMyRecords()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter("select * from Table1", con)
da.Fill(dt)

Dim myRow As DataRow
For Each myRow In dt.Rows


ListView1.Items.Add(myRow.Item(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myRow.Item(1))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myRow.Item(2))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myRow.Item(3))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myRow.Item(4))


Next
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Table1BindingSource.AddNew()

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TableAdapter.Update(Database21DataSet.Table1)

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Table1BindingSource.RemoveCurrent()

End Sub
End Class
Posted
Comments
Sergey Alexandrovich Kryukov 13-Mar-14 20:12pm    
Data Grid? Where is that? Which one? Full type name, please.
—SA

1 solution

I think you're missing BindingSource.EndEdit();

in my C# code I had a GridView but should work the same.

For update, I had:
C#
private void LoadLookupTable()
        {
            this.eventLookupTableAdapter.Fill(this.configDBDataSet.EventLookup);
            this.eventLookupBindingSource.DataSource = this.configDBDataSet.EventLookup;
        }

private void UpdateTable()
{
this.eventLookupBindingSource.EndEdit();
int n = this.eventLookupTableAdapter.Update(this.configDBDataSet.EventLookup);
this.LoadLookupTable();
}


For add and delete I accessed DataSet.DataTable.Rows.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900