i have button add and the coding, but everytime 1 click the button, a messagebox said that syntax error INSERT INTO. all database column name and the textbox name is true. i checked many times. this is my code
Try
'add data inside the database
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Bengkel\Project\db.mdb")
con.Open()
cmd = New OleDbCommand("INSERT into book (bookid,title,author,dateB,category,price,qty,image,status) VALUES('" & Me.bookid.Text & "','" & Me.title.Text & "','" & Me.author.Text & "','" & Me.datebook.Text & "','" & Me.cat.Text & "','" & Me.bookprice.Text & "','" & Me.qty.Text & "','" & Me.txtFilePathStaff.Text.ToString & "' ,'" & Me.stat.Text & "')", con)
Dim ConfirmAdd As System.Windows.Forms.DialogResult
ConfirmAdd = MessageBox.Show("Are You Sure Want To Add Data?", "Add", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If ConfirmAdd = System.Windows.Forms.DialogResult.Yes Then
a = cmd.ExecuteNonQuery()
MessageBox.Show("Data Saved ", "Save")
PBStaffPic.Image = Nothing
bookid.Clear()
title.Clear()
author.Clear()
datebook.Clear()
cat.Text = ""
bookprice.Clear()
qty.Clear()
stat.Text = ""
PBStaffPic.Image = Nothing
End If
Catch ex As System.Exception
MessageBox.Show(ex.Message)
End Try
con.Close()
note : i also use this code on other form, but it work. only this form got error. is my database table(book) got some problems?