0
cmd = New SqlCommand("select enrollment,total_fee,discount,net_fee from stu_dtl", openConnection())
' dr = cmd.ExecuteReader
adpt = New SqlDataAdapter(cmd)
adpt.Fill(ds, "stu_dtl")
dt = ds.Tables("stu_dtl")
For i = 0 To dt.Rows.Count - 1
cmd = New SqlCommand("update stu_dtl set net_fee = '" & (Val(dt.Rows(i).Item("total_fee")) - Val(dt.Rows(i).Item("discount"))) & "' where enrollment = '" & dt.Rows(i).Item("enrollment") & "'", openConnection())
cmd.ExecuteNonQuery()
Next
當我對超過150條記錄執行此代碼「Nothing happens」......我在做什麼錯誤?是否有任何其他方式更新?在循環內執行更新查詢
除非我錯過了某些東西,否則不需要任何代碼。只是創建一個SQL更新查詢和ExecuteNonQuery將做同樣的事情 – peterG