用VB如何比较ACCESS数据表中两列数据的大小并将结果写入另一个数据表中

问题比较急,不知道哪位能帮忙做个教详细的解答。谢谢!!!

假设你用ADO连接数据库,ADO对象为conn
记录指针对象为Rs
设表1的结构为
列1 列2 列3 列4
张三 5 6 4
李四 3 1 5
王五 5 7 9
赵六 2 3 4

表2结构为
列1

现在要将列2和列3中同一行的较大的数写入表2中
do while not rs.eof
sqlcmd="select 列2,列3 from 表1"
set rs=conn.execute(sqlcmd)
if rs(0)>rs(1) then
conn.execute("insert into 表2 value(" & rs(0) & ")" )
else
conn.execute("insert into 表2 value(" & rs(1) & ")" )
endif
rs.movenext
loop

如还有问题请百度HI联系
温馨提示:答案为网友推荐,仅供参考
相似回答