好了,這是我如何解決它。
在aspx.vb頁我做了以下
Dim bllCust As New bllCust
Dim objCust As New Cust
objCust.Custname = txtName.Text
objCust.CustBtwNr = txtBtw.Text
objCust.CustCode = txtCode.Text
objCust.CustAdminUserID = ddlUsers.SelectedValue
objCust.CustDealerID = ddlDealers.SelectedValue
'Edit+ checks
Try
bllCust.EditCust(objCust)
Catch ex As Exception
lblFeedback.Text = ex.Message
End Try
在bllCust:在dalCust
Public Function EditCust(ByVal objCust As Cust) As Boolean
<!-- I have checks here to see whether the values don't already excist. -->
If dataKlant.EditCust(objCust) Then
Throw New Exception("Customer was edited.")
Return True
Else
Throw New Exception("Customer couldn't be edited, try again.")
Return False
End If
End Function
後來總算:
Public Function EditCust(ByVal objCust As Cust) As Boolean
myconn.Open()
Dim result As New Boolean
Dim SQL As String = "update Cust set CustName= @CustName, CustCode = @CustCode where CustID= @CustID"
Dim cmd As New MySqlCommand(SQL, myconn)
cmd.Parameters.AddWithValue("@CustID", objCust.CustID)
cmd.Parameters.AddWithValue("@CustName", objCust.CustName)
cmd.Parameters.AddWithValue("@CustCode", objCust.CustCode)
result= cmd.ExecuteNonQuery()
myconn.Close()
Return result
End Function
這就是我是如何做到的。我也把荷蘭語翻譯成英文,所以每個人都能更好地理解它。
['UPDATE'](http://dev.mysql.com/doc/refman/5.0/en/update.html)查詢。如果您向我們展示了一些代碼,我們可以爲您的案例提供解決方案。 – Shef
爲我編輯我的文章。 – CustomX
哇...這是一種語言,我不「說話」。我想這是VB,你應該添加該標籤以及您的帖子。除此之外,還有一個函數定義缺少'bewerkKlant()'。 – Shef