Private Sub butup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butup.Click
Using con As New SqlConnection("data source=tiger;initial catalog=transport;uid=sa;pwd=47222420322")
con.Open()
Dim tr As SqlTransaction = con.BeginTransaction
For i As Integer = 0 To lv.Items.Count - 1
Dim cm As New SqlCommand("Update tblbbk1 set(keydate,tranid,proid,proname,box,trancost,bill,amount,typeid,zone) values (@a,@b,@c,@d,@e,@f,@g,@h,@i,@j)", con, tr)
With cm
.Parameters.AddWithValue("@a", dtp.Value.ToString("MM/dd/yyyy"))
.Parameters.AddWithValue("@b", cb1.SelectedValue)
.Parameters.AddWithValue("@c", lv.Items(i).SubItems(0).Text)
.Parameters.AddWithValue("@d", lv.Items(i).SubItems(1).Text)
.Parameters.AddWithValue("@e", txt3.Text)
.Parameters.AddWithValue("@f", txt4.Text)
.Parameters.AddWithValue("@g", CDbl(lv.Items(i).SubItems(4).Text))
.Parameters.AddWithValue("@h", txt6.Text)
.Parameters.AddWithValue("@i", ty.Text)
.Parameters.AddWithValue("@j", tz.Text)
.ExecuteNonQuery()
End With
Next
tr.Commit()
MessageBox.Show("บันทึกการแก้ไขข้อมูลเรียบร้อยแล้ว", "Database", MessageBoxButtons.OK)
'lv.Items.Clear()
End Using