I use the this code. showing "Update" msg but not update and if i add an item then show "Update" not "save"
Please help me.....
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Dim sql = "select Count(*) from pur_invdet where purinvid= txtpurinvid.text"
Dim cmd = New OleDb.OleDbCommand(sql, cn)
cmd.Parameters.AddWithValue("@purinvid", TextBox1.Text)
Dim result As Integer = Convert.ToInt32(cmd.ExecuteScalar())
cmd.Parameters.Clear()
cmd.Dispose()
If result > 0 Then
For Each x As ListViewItem In ListView1.Items
Dim sln As Integer = x.SubItems(0).Text
Dim qty As Integer = Convert.ToDecimal(x.SubItems(4).Text)
Dim itmid As Integer = x.SubItems(12).Text
Next
sql = "Update pur_invdet set [slno] = [slno] + sln where purinvid= txtpurinvid.text"
cmd = New OleDb.OleDbCommand(sql, cn)
cmd.Parameters.AddWithValue("@slno", Val(txtitemsl.Text))
cmd.Parameters.AddWithValue("@ItemIDpur", txtitemid.Text)
cmd.Parameters.AddWithValue("@purinvid", txtpurinvid.Text)
cmd.ExecuteNonQuery()
MsgBox("Updated")
Else
sql = "Insert into pur_invdet (slno, ItemIDpur,purinvid) values (@slno, @ItemIDpur, @purinvid)"
cmd = New OleDb.OleDbCommand(sql, cn)
cmd.Parameters.AddWithValue("@slno", Val(txtitemsl.Text))
cmd.Parameters.AddWithValue("@ItemIDpur", txtitemid.Text)
cmd.Parameters.AddWithValue("@purinvid", txtpurinvid.Text)
cmd.ExecuteNonQuery()
MsgBox("Save")
End If