'i got a problem here. i want to add a new record to my database but when i click the add button an error occurs saying syntax error on INSERT INTO statement. it is placed on the da.update(ds, "studentprofile")
what should i do?? here's the code:
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsnewrow As DataRow
dsnewrow = ds.Tables("studentprofile").NewRow()
dsnewrow.Item(1) = txtlastname.Text
dsnewrow.Item(2) = txtfirstname.Text
dsnewrow.Item(3) = txtmiddlename.Text
dsnewrow.Item(4) = txtgender.Text
dsnewrow.Item(5) = txtage.Text
dsnewrow.Item(6) = txtlevel.Text
dsnewrow.Item(7) = txtcourse.Text
dsnewrow.Item(8) = txtaddress.Text
dsnewrow.Item(9) = DateTimePicker1.Value
dsnewrow.Item(10) = txtnationality.Text
dsnewrow.Item(11) = txtplaceofbirth.Text
dsnewrow.Item(12) = txtcivilstatus.Text
dsnewrow.Item(13) = txtcontactnumber.Text
dsnewrow.Item(14) = txtguardian.Text
dsnewrow.Item(15) = txtrelationship.Text
dsnewrow.Item(16) = txtguardiancontact.Text
ds.Tables("studentprofile").Rows.Add(dsnewrow)
da.Update(ds, "studentprofile")
MsgBox("New record added.", MsgBoxStyle.Information)
btnupdate.Enabled = True
Else
incdec = 0
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsnewrow As DataRow
dsnewrow = ds.Tables("studentprofile").NewRow()
dsnewrow.Item(1) = txtlastname.Text
dsnewrow.Item(2) = txtfirstname.Text
dsnewrow.Item(3) = txtmiddlename.Text
dsnewrow.Item(4) = txtgender.Text
dsnewrow.Item(5) = txtage.Text
dsnewrow.Item(6) = txtlevel.Text
dsnewrow.Item(7) = txtcourse.Text
dsnewrow.Item(8) = txtaddress.Text
dsnewrow.Item(9) = DateTimePicker1.Value
dsnewrow.Item(10) = txtnationality.Text
dsnewrow.Item(11) = txtplaceofbirth.Text
dsnewrow.Item(12) = txtcivilstatus.Text
dsnewrow.Item(13) = txtcontactnumber.Text
dsnewrow.Item(14) = txtguardian.Text
dsnewrow.Item(15) = txtrelationship.Text
dsnewrow.Item(16) = txtguardiancontact.Text
ds.Tables("studentprofile").Rows.Add(dsnewrow)
da.Update(ds, "studentprofile")
MsgBox("New record added.", MsgBoxStyle.Information)
btnupdate.Enabled = True
End If
End Sub
end class