0
Dim da2 As OleDb.OleDbDataAdapter
        Dim cols As Integer = Attendance_QueryDataGridView.ColumnCount
        Dim rows As Integer = Attendance_QueryDataGridView.Rows.Count
        Dim a(cols) As String
        Dim dt As New DataTable("Attendance")

        da2 = New OleDb.OleDbDataAdapter(sql, con)
        da2.Fill(ProjectDataSet, "Attendance")
        Dim NewRow As DataRow
        NewRow = ProjectDataSet.Tables("Attendance").NewRow
        For z = 0 To cols - 1
            a(z) = Attendance_QueryDataGridView.Columns(z).HeaderText
                dt.Columns.Add(a(z))


        Next


        For x = 0 To rows - 2
            NewRow("RainbowID") = Attendance_QueryDataGridView.Item(0, x).Value

           
            For y = 3 To cols
                For z = 3 To cols - 3
                    NewRow(a(z)) = Attendance_QueryDataGridView.Item(y, x).Value

                Next
            Next
        Next
        dt.NewRow()
             da.Update(dt)

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
2
Replies
7
Views
7 Years
Discussion Span
Last Post by shrighead
0

>How do i save a query from datagridview back to the database table?

The answer is - DataAdapter and relational class (DataSet/DataTable).

0

What is a relational class? I tried adding to a new datatable but it then won't let new columns be added to the table in access

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.