有问题hi我
Option Explicit
Dim Cn As New ADODB.Connection
Dim Cnc As New ADODB.Command
Private Sub Command1_Click()
Dim Rs As New ADODB.Recordset, Rs1 As New ADODB.Recordset
Dim Sql As String
Dim i As Integer
Rs.Open "select * from 表1 where 条件", Cn, adOpenStatic, adLockBatchOptimistic
Rs1.Open "select * from 表2", Cn, adOpenStatic, adLockBatchOptimistic
For i = 0 To Rs.RecordCount - 1
Rs1.AddNew
Rs1!字段1 = Rs!字段1
.
.
Rs1!字段n = Rs!字段n
Rs1.UpdateBatch
Rs.MoveNext
Next
With Cnc
.ActiveConnection = Cn
.CommandType = adCmdText
.CommandText = "select * from 表1 where 条件"
.Execute
End With
MsgBox "数据更新成功!"
End Sub
Private Sub Form_Load()
oDataSource = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") & "数据库名称.mdb"
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Trim(oDataSource) & ";Persist Security Info=False"
Cn.CursorLocation = adUseClient
Cn.Open
End Sub