plsss I need help!!
I have problem with my insert data into database
this is my code
Public Sub doSave()
Dim con As New OleDb.OleDbConnection(My.Settings.SystemDataConnectionString)
Dim cmd As New OleDb.OleDbCommand
Dim adap As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim dr As OleDb.OleDbDataReader
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\D_S_S - DATA\D_S_S\DSReS\SystemData.mdb;Persist Security Info=True")
con.Open()
cmd.CommandText = "SELECT * FROM tblVehicle WHERE VehiclePlat ='" & TxtPlat.Text & "'"
cmd = New OleDbCommand(cmd.CommandText, con)
dr = cmd.ExecuteReader()
If Not dr.HasRows Then
cmd.CommandText = " INSERT INTO tblVehicle (VehicleNo,vehicleModel,vehiclePlat,Type of License,TotalOfDriver) VALUES ('" + TxtNo.Text + "','" + TxtModel.Text + "','" + TxtPlat.Text + "','" + CmbLicense.Text + "','" + CmbDriver.Text + "')"
cmd = New OleDbCommand(cmd.CommandText, con)
cmd.Connection = con
cmd.ExecuteNonQuery()
MessageBox.Show("Data has been successfully saved.", "Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
adap = New OleDbDataAdapter("Select * from tblVehicle", con)
adap.Fill(ds, "1")
TblVehicleDataGridView1.DataSource = ds.Tables("1")
Me.TblVehicleDataGridView1.Rows(Me.TblVehicleDataGridView1.RowCount - 2).Selected = True
con.Close()
Else
MsgBox(" Vehicle record exist")
End If
End Sub
(ERROR) at cmd.ExecuteNonQuery()
= Syntax error in INSERT INTO statement.