我的代码有问题。问题是我无法获取 ID。
这是我的代码。
Private Sub UpdatePurchase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txtID.Text = PassName
txtName.Text = PassID
cqty.Text = Passqty
cucost.Text = Passucost
ctotal.Text = Passtotal
End Sub
Private Sub Updatebtn()
tqty.Text = Val(cqty.Text) + Val(qtyText.Text)
tucost.Text = Val(cucost.Text) + Val(cucost.Text)
ttotal.Text = Val(tucost.Text) * Val(tqty.Text)
Dim sql As String = "UPDATE tblPurchase SET itemQuantity='" + tqty.Text + "',UnitCost='" + tucost.Text + "',TotalCost='" + ttotal.Text + "'WHERE purchaseID='" + txtName.Text + "'"
Try
con.Open()
If cmd.ExecuteNonQuery() > 0 Then
MsgBox("Purchased Successfully Updated")
cleartxt()
End If
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
End Sub