vb实现Access把一组数据从一个数据库转到另一个数据库

比如设计一个按钮command1,点击它,就能实现把当前文件夹中library库A2表中一组数据转到mybook库A3表,此时A2表同时删除此数据,成功后MsgBox”成功“。数据例子为书名,作者,出版社。
哪位大神能直接给出代码谢谢了

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\library.mdb;Persist Security Info =false"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from A2" '当前文件夹中library库A2表中数据Adodc1.Refresh

Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mybook.mdb;Persist Security Info =false"
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from A3" 当前文件夹中mybook库A3表数据
Adodc2.Refresh

If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst 'A2表中数据集指针到最前面
If Not Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveLast 'A3数据集指针到最后
For i = 1 To Adodc1.Recordset.RecordCount
Adodc2.Recordset.AddNew 'A3添加空数据
Adodc2.Recordset.Fields(0).Value = Adodc1.Recordset.Fields(0).Value '将A2当前指针的数据给A3新加数据表中
Adodc2.Recordset.Update 'A3更新
Adodc1.Recordset.MoveNext 'A2指向下一条继续
Next i
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-04-28
病情分析:
过敏性哮喘患者饮食最基本原则就是清淡、松软,适宜多吃易消化且含纤维素丰富的食物,如丝瓜、香蕉、梨等;少吃鸡蛋、肥肉等容易生痰的食物。
指导意见:
由于过敏性哮喘多由过敏因素诱发,因此鱼、虾、河蚌、蟹等腥膻的海味食物以及羊肉、肥肉、鸡蛋、花生、巧克力、糖果、蜂蜜等甜腻食物,应该少吃或最好不吃。

病情分析:
1、避免温差变化,注意保暖,2、预防和及时治疗感冒,3、预防常见过敏原刺激,包括环境和饮食控制,4、避免剧烈运动和疲劳,部分与内分泌或精神有关,注意预防。5、规范治疗,6、原因不同,治疗和预防的方法就不同。
指导意见:
你好:常见致敏食物包括:(一)动物蛋白食品:包括牛奶、鸡蛋、鱼、虾、蟹、羊肉、牛肉、猪肉,鸡肉及其它禽类等。(二)油料作物及坚果类:包括芝麻、花生、黄豆、核桃、榛子、开心果、腰果等。(三)水果及蔬菜类:包括桃、梨、苹果、橘子、荔枝、西瓜、扁豆、番茄、茄子等。(四)谷类:小麦、燕麦、荞麦、玉米等。(五)食物添加剂:以食用色素、防腐剂为主。

你好,过敏性哮喘的饮食宜温热、清淡、松软,可少食多餐。除了忌食肯定会引起过敏或哮喘的食物以外,应避免对其他食物忌口,以免失去应有的营养平衡。在哮喘发作时,还应少吃胀气或难消化的食物,如豆类、山芋等,以避免腹胀压迫胸腔而加重呼吸困难。
第2个回答  2016-01-26
使用2个数据连接,
全部打开,按条插入

如:dim conn1 as adodb.connection, conn2 as adodb.connection
dim sqlstr as string
sqlstr = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=456123;Data Source=" & App.Path & "\DB.mdb;Persist Security Info=True"
Set conn1 = New ADODB.Connection
conn1.CursorLocation = adUseClient
conn1.Open sqlstr

sqlstr = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=456123;Data Source=" & App.Path & "\DB1.mdb;Persist Security Info=True"
Set conn2 = New ADODB.Connection
conn2.CursorLocation = adUseClient
conn2.Open sqlstr

dim rs as adodb.recordset
dim i as integer, fieldCount as integer

set rs = conn1.execute("select * from table1")
if rs.eof then exit sub
fieldCount = rs.Fields.Count

do while rs.eof = false
sqlstr = "insert into table1 values('"
for i = 0 to fieldCount - 2
sqlstr = sqlstr & rs.fields(i) & "','"
next i
sqlstr = sqlstr & rs.fields(i) & "')"
conn2.execute(sqlstr)
rs.movenext
loop

rs.close
conn1.close
conn2.close
第3个回答  2019-09-17
需要,Mark备用
相似回答