I have a program with DataGridView which is bound to MS Access table. When I addept to update I get "Syntax error in INSERT INTO", but no explanation about the syntax error. Column names in the table have a space in them, such as "Last Name". Could that be the problem? Most of this code comes from a tutorial I'm studying.
Public Class Form1
Dim binding_source As New BindingSource()
Dim data_table As New DataTable()
Dim data_adapter As OleDb.OleDbDataAdapter
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.DataGridView1.DataSource = Me.binding_source
Dim conString As String = My.Settings.MyContactsConnectionString
Dim con As New OleDb.OleDbConnection(conString)
con.Open()
data_adapter = New OleDb.OleDbDataAdapter("SELECT * FROM Contacts", con)
Dim cb As New OleDb.OleDbCommandBuilder(data_adapter)
data_adapter.Fill(data_table)
binding_source.DataSource = data_table
End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Me.data_adapter.Update(CType(Me.binding_source.DataSource, DataTable))
MessageBox.Show("Database Updated")
End Sub
End Class