新建一个工程,将下面代码复制到窗体的load事件里。然后将数据库复制到跟程序一个目录。在工程里引用microsoft activex data objects 27 library
Private Sub Form_Load()
Dim cn As ADODBConnection
Dim cn1 As ADODBConnection
Dim rs As ADODBRecordset
Dim rs1 As ADODBRecordset
Set cn = New ADODBConnection
Set cn1 = New ADODBConnection
Set rs = New ADODBRecordset
Set rs = New ADODBRecordset
cnConnectionString = "Provider=MicrosoftJetOLEDB40;Persist Security Info=False;Jet OLEDB:Database Password = astone;Data Source=" & AppPath & "\1mdb"
cn1ConnectionString = "Provider=MicrosoftJetOLEDB40;Persist Security Info=False;Jet OLEDB:Database Password = astone;Data Source=" & AppPath & "\2mdb"
cnOpen
cn1Open
rsOpen "select from info ", cn, adOpenStatic, adLockOptimistic
rs1Open "select from info ", cn1, adOpenStatic, adLockOptimistic
Do While Not rsEOF
rs1AddNew
rs1!字段1 = rs!字段1 '有多少字段下面写多少,字段1,2,3是字段名
rs1!字段2 = rs!字段2
rs1!字段3 = rs!字段3
rs1Update
Loop
rsClose
rs1Close
End Sub
dim Sql,Rs,Rs2,tstr,i
conn="Driver={Microsoft Access Driver (mdb)};DBQ=" & servermappath("数据库路径和名称")
Set Rs2 = ServerCreateObject("ADODBRecordSet")
Sql = "SELECT TOP 1 FROM tabletwo"
Rs2Open Sql, Conn, 1, 2
Set Rs = ServerCreateObject("ADODBRecordSet")
Sql = "SELECT CONTENT FROM tableone"
RsOpen Sql, Conn, 1, 2
Do Until RsEof
For i = 1 To 10
If RsEof Then Exit For
tstr = tstr & Rs("CONTENT") & ","
RsMoveNext
Next
If tstr <> "" Then
tstr = Left(tstr, Len(tstr)-1)
Rs2AddNew
Rs2("CONTENT") = tstr
Rs2Update
End If
tstr = ""
Loop
Rs2Close
RsClose
Set Rs2 = Nothing
Set Rs = Nothing
以上就是关于有两个ACCESS文件分别是1.mdb、2.mdb,它们里面都有相同的表名为info,如何把各1.mdb合并到2.mdb全部的内容,包括:有两个ACCESS文件分别是1.mdb、2.mdb,它们里面都有相同的表名为info,如何把各1.mdb合并到2.mdb、Access中数据合并怎么 *** 作、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)