S
Scott H.
I'm trying to use an OleDbDataAdapter along with the OleDbCommandBuilder to
update a Microsoft Access table from a DataGridView using vb.NET. THe
DataGridView is populated correctly. If I make a change to the DataGridView
and click Button1 to update the table, the following error is generated:
Syntax error (missing operator) in query expression .....
This works fine when I use the SQL version of the dataadapter and
commanbulder when updating a table in SQL Server. Any ideas as to why this
does not work with Access?
Thanks.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim Cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\AMCO\SNAP Support Files.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM
Default_Settings_Table", Cn)
Cn.Open()
myDA = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
builder.RefreshSchema()
myDataSet = New DataSet()
myDA.Fill(myDataSet, "MyTable")
DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
Cn.Close()
Cn = Nothing
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Validate()
Me.myDA.Update(Me.myDataSet.Tables("MyTable"))
Me.myDataSet.AcceptChanges()
End Sub
update a Microsoft Access table from a DataGridView using vb.NET. THe
DataGridView is populated correctly. If I make a change to the DataGridView
and click Button1 to update the table, the following error is generated:
Syntax error (missing operator) in query expression .....
This works fine when I use the SQL version of the dataadapter and
commanbulder when updating a table in SQL Server. Any ideas as to why this
does not work with Access?
Thanks.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim Cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\AMCO\SNAP Support Files.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM
Default_Settings_Table", Cn)
Cn.Open()
myDA = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDA)
builder.RefreshSchema()
myDataSet = New DataSet()
myDA.Fill(myDataSet, "MyTable")
DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
Cn.Close()
Cn = Nothing
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Validate()
Me.myDA.Update(Me.myDataSet.Tables("MyTable"))
Me.myDataSet.AcceptChanges()
End Sub