我需要从Access表中获取数据,并在对其进行编辑后,再次将其保存在同一表中。我需要使用FOR ..下一个周期。
我目前使用VB6和ADO。我不能在VB.net和ADO.net中做到这一点。您可以为我将这些例程从VB.6转换为VB。净。在MSFlexGrid
帖子中,我使用了DataGridView
。
Sub Carica()
Set RSConti = New ADODB.Recordset
Set CnnDB = New ADODB.Connection
CnnDB.CursorLocation = adUseClient
CnnDB.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Jet OLEDB:Database Password= " & AccessPassword & " ;Data Source=" & indir2
RSConti.Open "Select * From TabA", CnnDB, adOpenStatic, adLockOptimistic
**With MSFlexGrid1
For numRow = 0 To .Rows - 1
For numCol = 0 To .Cols - 1
.TextMatrix(numRow, numCol) = RSConti.Fields(numCol) & ""
Next numCol
RSConti.MoveNext
Next numRow
End With**
RSConti.Close
Set RSConti = Nothing
End Sub
Sub Salva()
Set RSConti = New ADODB.Recordset
Set CnnDB = New ADODB.Connection
CnnDB.CursorLocation = adUseClient
CnnDB.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database password= " & AccessPassword & ";Data Source=" & indir2
RSConti.Open "Select * From TabA", CnnDB, adOpenStatic, adLockOptimistic
**CnnDB.Execute "DELETE * From TabA"
With MSFlexGrid1
For numRow = 0 To .Rows - 1
RSConti.AddNew
For numCol = 0 To .Cols - 1
RSConti(numCol) = .TextMatrix(numRow, numCol)
Next numCol
RSConti.Update
Next numRow
End With**
RSConti.Close
Set RSConti = Nothing
End Sub