VB操作ACCESS数据库的有关问题
VB操作ACCESS数据库的问题
------解决方案--------------------
cnn.Execute ("INSERT INTO b SELECT id, [name], num FROM a")
- VB code
'我想把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
------解决方案--------------------
cnn.Execute ("INSERT INTO b SELECT id, [name], num FROM a")