------------------------------------- Private Sub TEST() Using cn As New OleDb.OleDbConnection(接続文字列)
Dim da As OleDb.OleDbDataAdapter Dim ds As DataSet Dim dt As DataTable Dim dr() As DataRow Dim i As Integer Dim cmd As OleDbCommand
Dim strSelect As String Dim strUpdate As String
strSelect = "select * from [テーブルA]" da = New OleDbDataAdapter(strSelect, cn) ds = New DataSet da.Fill(ds, "テーブルA") dt = ds.Tables("テーブルA") dr = dt.Select
For i = 0 To dr.Length - 1 strUpdate = "update [テーブルA]" & " set [フィールドP]=[値] where [ID]=" & dr(i)("ID") & "" cmd = New OleDbCommand cmd.Connection = cn cmd.CommandText = strUpdate cmd.ExecuteNonQuery() Next
------------------------------------- Private Sub TEST() Using cn As New OleDb.OleDbConnection(接続文字列)
Dim da As OleDb.OleDbDataAdapter Dim ds As DataSet Dim dt As DataTable Dim dr() As DataRow Dim cb As OleDbCommandBuilder Dim i As Integer Dim strSelect As String
strSelect = "select * from [テーブルA]"
da = New OleDbDataAdapter(strSelect, cn) ds = New DataSet da.Fill(ds, "テーブルA") dt = ds.Tables("テーブルA") dr = dt.Select
cb = New OleDbCommandBuilder(da)
For i = 0 To dr.Length - 1 dr(i).BeginEdit() dr(i)("フィールドP") = [値] dr(i).EndEdit() Next