Results 1 to 2 of 2
  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2013
    Norco, CA

    How to save Datatable

    Name:  Form.jpg
Views: 257
Size:  15.9 KB

    I'm trying to save the entire datatable. The datatable is named DataTableGrid1. Any suggestions why this isnt working.


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim sql As String
            sql = String.Format("insert * from notes")
            Dim con = db.GetConnection
            Dim cmd As New OleDbCommand(sql, con)
            Dim ds As New DataSet
            Dim da As New OleDbDataAdapter(cmd)
            'lookup dataset changes
            da.Update(DataGridView1) 'Fill Dataset with Table data
        End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: How to save Datatable

    It's not working for a number of reasons. I suggest that you follow the CodeBank link in my signature below and check out my thread on Retrieving & Saving Data to see how to use a data adapter and a DataTable. After populating the DataTable, you can bind it to a BindingSource and then bind that to the grid, e.g.
    Me.BindingSource1.DataSource = myDataTable
    Me.DataGridView1.DataSource = Me.BindingSource1
    When you're ready to save, call EndEdit on the BindingSource before calling Update on the data adapter.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.