VB操作ACCESS数据库的问题

苏克贝塔03 2012-10-10 09:27:52
 '我想把a表中的3个字段的内容全部复制到b表中,但是这样不行啊,请大家帮帮忙
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Connection
Dim tem_id As Double
Dim tem_name As Double
Dim tem_num As Integer

Set rst = cnn.Execute("select * from a")
rst.MoveFirst
If Not rst.EOF Then
Set rst = cnn.Execute("select id from a")
tem_id = rst(0).value
Set rst = cnn.Execute("select name from a")
tem_name = rst(0).value
Set rst = cnn.Execute("select num from a")
tem_num = rst(0).value
cnn.Execute ("INSERT INTO b (id,name , num) VALUES (" & tem_id & "," & tem_name & "," & tem_num & ")")
rst.MoveNext
End If
...全文
117 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
苏克贝塔03 2012-10-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
cnn.Execute ("INSERT INTO b SELECT id, [name], num FROM a")
[/Quote]
是的啊,解决了。
我多想了,谢谢你啊。
of123 2012-10-10
  • 打赏
  • 举报
回复
cnn.Execute ("INSERT INTO b SELECT id, [name], num FROM a")

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧