Good Day,
I am have this error System.NullReferenceException:Object reference not set to an instance of an object. when i trigger the update button. I have a listview in my form 1 so i can add data which is working fine and accepting blank values so the user can add data in the future. but when i am trying to INSERT... DUPLICATE KEY ON UPDATE i am having this error.
Dim cmd6 As New MySqlCommand(cs, conn2)
With cmd6
.CommandText = "INSERT INTO workrecord (entryno, empid2, position, company, sdate, edate, yoservice, reason)" _
& "VALUES (@entryno, @empid2, @position, @company, @sdate, @edate, @yoservice, @reason)" _
& "ON DUPLICATE KEY UPDATE entryno = @entryno, empid2 = @empid2, position = @position, company = @company, sdate = @sdate, edate = @edate, yoservice = @yoservice, reason = @reason"
.Parameters.AddWithValue("@entryno", itm1.Text)
.Parameters.AddWithValue("@empid2", itm1.SubItems(1).Text)
.Parameters.AddWithValue("@position", itm1.SubItems(2).Text)
.Parameters.AddWithValue("@company", itm1.SubItems(3).Text)
.Parameters.AddWithValue("@sdate", itm1.SubItems(4).Text)
.Parameters.AddWithValue("@edate", itm1.SubItems(5).Text)
.Parameters.AddWithValue("@yoservice", itm1.SubItems(6).Text)
.Parameters.AddWithValue("@reason", itm1.SubItems(7).Text)
.ExecuteNonQuery()
End With