Hi I am trying to add a date field from vb 2005 to access database. However when I try to run the following code I gets error message that reads “Syntax error in INSERT INTO statement.” Any help regarding this is highly apprecited.
[code]
Imports System.Data
Imports System.Data.Common
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sql = “select date from Table1”
con.ConnectionString = “PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = F:\vb office\test\test.mdb”
con.Open()
da = New OleDb.OleDbDataAdapter(sql, con)
Dim dr As DataRow
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds, “Table1”)
dr = ds.Tables(“Table1”).NewRow()
dr(“date”) = CDate(TextBox1.Text)
ds.Tables(“Table1”).Rows.Add(dr)
‘da.FillSchema(ds, SchemaType.Mapped, “Table1”)
da.Update(ds, “Table1”)
MessageBox.Show(“data”)
End Sub
End Class
[code]