我有一個數據網格view..in更新按鈕,我寫這樣的如何循環扔在vb.net windows應用程序
Dim cid As Integer
Dim dtid As Integer
Dim cmpname As String
Dim dtname As String
Dim dtPhone As String
Dim dtEmail As String
Dim rv = DirectCast(bSource.Current, DataRowView)
cid = rv.Row.Field(Of Integer)("Cid")
dtid = rv.Row.Field(Of Integer)("dtId")
cmpname = rv.Row.Field(Of String)("CompanyName")
dtname = rv.Row.Field(Of String)("dtName")
dtPhone = rv.Row.Field(Of String)("dtPhone")
dtEmail = rv.Row.Field(Of String)("dtEmail")
adapter.UpdateCommand = New SqlCommand("UPDATE CompanyMaster_tbl SET CompanyName = @CompanyName", con)
adapter.UpdateCommand = New SqlCommand("update DepartmentMaster_tbl set dtName = @dtName,dtPhone = @dtPhone,dtEmail = @dtEmail where [email protected]", con)
adapter.UpdateCommand.Parameters.AddWithValue("@Cid", cid)
adapter.UpdateCommand.Parameters.AddWithValue("@CompanyName", cmpname)
adapter.UpdateCommand.Parameters.AddWithValue("@dtId", dtid)
adapter.UpdateCommand.Parameters.AddWithValue("@dtName", dtname)
adapter.UpdateCommand.Parameters.AddWithValue("@dtPhone", dtPhone)
adapter.UpdateCommand.Parameters.AddWithValue("@dtEmail", dtEmail)
adapter.UpdateCommand.ExecuteNonQuery()
我在datagridview.same新的代碼在數據網格視圖中的所有行時間如果我更新多行,它影響最後更新的行,,所以我需要循環拋出datagridview中的所有行..如何我可以實現的..
所以我給了這樣的循環內的整個代碼
For Each row As DataGridViewRow In gv.Rows
'my code here
Next
,但隨後還更新最後更新的行?在此先感謝
先生,,我給出這樣的代碼只....但要更新我的最後一行編輯先生 – user3106114
,,我的每個循環有什麼問題? – user3106114