Hi again............
I'm having problems in saving the data in my datagrid to my Database
Imports System.Data.OleDb
Public Class Form2
Dim con As New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\RMC\Documents\Vehicle.accdb;")
Dim cmd As OleDbCommand
Dim adpt As OleDbDataAdapter
Dim cb As OleDbCommandBuilder
Dim sql, lol As String
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
adpt = New OleDbDataAdapter("Select * From Data1", con)
Dim DtSet As New DataSet
adpt.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)
con.Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
adpt = New OleDbDataAdapter("Select * From Data1", con)
Dim DtSet As New DataSet
adpt.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)
Else
adpt = New OleDbDataAdapter("Select * From Data1 WHERE [Plate#] Like '" & TextBox1.Text & "%'", con)
Dim DtSet As New DataSet
adpt.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)
End If
End Sub
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
cb = New OleDbCommandBuilder(adpt)
Dim DtSet As New DataSet
Validate()
adpt.Update(DtSet.Tables("Data1"))
End Sub
End Class
It says "Value cannot be null. Parameter name: dataTable". I also tried changing "DtSet.Tables("Data1")" to "DtSet.Tables(0)" and it says cannot find table 0