this is my code which i try to insert records but gives an error ...i hav a form with text box,combobox and datetime picker
my acess db format is
enq no is an auto number and
enqdate ,due date is date time of short date others are text plz do help
error is syntax error in insert into
VB.NET:
Private Sub btnadd_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
Dim ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=sample.mdb"
Dim sqlinsert As String
cmdadp = New OleDbDataAdapter(ConnectionString, cnnOLEDB)
[B]sqlinsert = "Insert into sample values(" & txtno.Text & ",'" & dtdate1.Value.ToShortDateString & "','" & cbbdiv.SelectedValue() & "','" & cbbpersonnel.SelectedValue() & "', '" & cbbnames.SelectedValue() & "'," & txtdetails.Text & "," & txtreports.Text & "," & txtremarks.Text & "," & txtadvice.Text & "," & txtrmksales.Text & ", " & txtrfq.Text & ",'" & dtdate.Value.ToShortDateString & "','" & cbbstatus.SelectedValue() & "')"[/B]
cnnOLEDB = New OleDb.OleDbConnection(ConnectionString)
cmdOLEDB = New OleDbCommand(sqlinsert, cnnOLEDB)
cnnOLEDB.Open()
cmdOLEDB.CommandText = sqlinsert
cmdOLEDB.Connection = cnnOLEDB
cmdOLEDB.ExecuteNonQuery()
ra = cmdOLEDB.ExecuteNonQuery()
MessageBox.Show("New Row Inserted" & ra)
ConnectionString.Close()
End Sub
enq no is an auto number and
enqdate ,due date is date time of short date others are text plz do help
error is syntax error in insert into
Last edited by a moderator: