如何在一次更新多行 [英] How to update multiple row at time
本文介绍了如何在一次更新多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,我想要及时更新多行
这是我的代码
Hi friends i want to update multiple rows at time
Here is my code
Dim a As Integer
Dim alar As New ArrayList
For a = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(a).Cells(0).Selected = True Then
alar.Add(DataGridView1.Rows(a).Cells("cardno").Value)
DataGridView2.Rows.Add(DataGridView1.Rows(a).Cells(0).Value, DataGridView1.Rows(a).Cells(1).Value, DataGridView1.Rows(a).Cells(2).Value, DataGridView1.Rows(a).Cells(3).Value, DataGridView1.Rows(a).Cells(4).Value)
End If
Next
'--------------------------------------------------
Dim count As Integer = alar.Count
Dim dsfs = alar.Item(0).ToString
'---------------------------------------------------
For i = 0 To alar.Count - 1
dsfs = alar.Item(0).ToString
Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
cn.ConnectionString = My.Settings.trialConnectionString
cn.Open()
cmd.Connection = cn
cmd.CommandType = CommandType.Text
' For i = 0 To DataGridView1.Rows.Count - 1
Dim ab As String
ab = DataGridView1.CurrentRow.Cells("cardno").Value
cmd.CommandText = "update voter set Castt='" & ToolStripComboBox1.Text & "' where cardno= '" & alar.Item(0).ToString & "'"
cmd.ExecuteNonQuery()
' Next
cn.Close()
Next
If res > 0 Then
MsgBox("Record Not Update")
al.Clear()
Else
MsgBox("Record Update")
End If
'End If
'---------------Roemove selected row int gridview------------------'
Dim row As Integer
Dim selRow As New DataGridViewRow
Dim index As Integer
index = DataGridView1.SelectedRows.Item(0).Index
selRow = DataGridView1.Rows.Item(index)
DataGridView1.Rows.Remove(selRow)
row = row - 1
End If
' MsgBox("Allocate Voter to " + ToolStripComboBox1.Text)
End If
在此代码中只有一条记录会更新
请帮帮我........
提前致谢.......
In this code only one record will update
Please help me........
Thanks in advance.......
推荐答案
访问这里..
< a href =https://code.exacttarget.com/question/how-update-multiple-data-extension-rows-one-time> https://code.exacttarget.com/question/how-update-multiple -data-extension-rows-one-time [ ^ ]
visit here..
https://code.exacttarget.com/question/how-update-multiple-data-extension-rows-one-time[^]
这篇关于如何在一次更新多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文