Option Explicit
Private conn1 As ADODB.Connection
Private rs1 As ADODB.Recordset
Private conn2 As ADODB.Connection
Private rs2 As ADODB.Recordset
Private Sub Command3_Click()
Dim dbfilename As String
Dim strsql As String
Dim ConnectString As String
Dim i As Integer
Set conn1 = New ADODB.Connection
dbfilename = "F:\csdn_vb\database\listbox\article1.mdb"
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbfilename & ";Persist Security Info=False;"
conn1.Open ConnectString
Set conn2 = New ADODB.Connection
dbfilename = "F:\csdn_vb\database\listbox\article2.mdb"
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbfilename & ";Persist Security Info=False;"
conn2.Open ConnectString
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
For i = 0 To rs1.RecordCount - 1
rs2.AddNew
rs2.Fields("mc") = rs1.Fields("mc")
rs2.Fields("memo") = rs1.Fields("memo")
rs2.Update
rs1.MoveNext
Next
End Sub
用两个recordset啦.
dim retsource as new adodb.recordset
dim retdec as new adodb.recordset
dim con as new adodb.connection
con.connectionstring="driver={sql server};server=;uid=sa;pwd=;database=数据库名称"
retsource.cursorlocation=adoclinet
retsource.open "select * from ",con
retdec.open "要插入的那个表"
for i= 0 to retsource.recordcount
retdec.addnew
for j=0 to retsoure.fields.count-1
retdec.fields(j)=retsource.fields(j)
next j
retdec.update
retsource.movenext
next i
搞掂.不过速度很慢.
建议用insert intto tablename select field1,field2 from tablename where....