0

Hello: I have an unbound datagrid and I'm trying to save it's contents to my access database.

here's my code thus far:

Dim dt As New DataTable()
            Dim dr As DataRow = Nothing
            For j As Integer = 0 To (Me.DataGridView1.RowCount - 1) - 1
                dr = dt.NewRow()
                If j < 1 Then
                    For k As Integer = 0 To Me.DataGridView1.ColumnCount - 1
                        dt.Columns.Add()
                    Next
                End If

                For i As Integer = 0 To Me.DataGridView1.ColumnCount - 1
                    If Me.DataGridView1.Item(i, j).Value <> "" Then
                        
'it wants to go through all the records...how can i look to see if the cell has been edited or not? 
dr.Item(i) = Me.DataGridView1.Item(i, j).Value.ToString()
                    End If
                Next
                If j > 0 Then
                    dt.Rows.Add(dr)
                End If
            Next

How do I tell it to save to my database?


Any help is truly appreciated.
Thank you very much,
Proctor

2
Contributors
1
Reply
5
Views
9 Years
Discussion Span
Last Post by Tarang Raval
0

Private Sub cmbsd_click()


If cmbsd.Text = "1" Then
q = "select *from std1 where year=" & year.Text & " "
r.CursorLocation = adUseClient

r.Open q, cn, adOpenDynamic, adLockOptimistic
Set DataGrid2.DataSource = r

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.