Guys when i run the code below i get this error:-Object reference not set to an instance of an object. everything is initialized and there are no empty fields in the database please help !
Dim con As New OleDbConnection
Dim cmd2 As New OleDbCommand
con.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\mydb.accdb")
cmd2.CommandText = "update items set itmbrcd=@p5,itemname=@p1,itemprice=@p2,itemGroup=@group,remarks=@p3,vat=@p6 where itmcode=@p4"
cmd2.Connection = con
con.Open()
cmd2.Parameters.AddWithValue("@p5", ItmBrcdTextBox.Text)
cmd2.Parameters.AddWithValue("@p1", ItemNameTextBox.Text)
cmd2.Parameters.AddWithValue("@p2", ItemPriceTextBox.Text)
cmd2.Parameters.AddWithValue("@group", ItemGroupComboBox.SelectedItem.ToString)
cmd2.Parameters.AddWithValue("@p3", RemarksTextBox.Text)
cmd2.Parameters.AddWithValue("@p4", ItmcodeTextBox.Text)
cmd2.Parameters.AddWithValue("@p6", VatNumericUpDown.Value)
cmd2.ExecuteNonQuery()
MsgBox("item updated!")
con.Close()