日期:2014-05-19  浏览次数:20466 次

初学者想提个问题,希望大家能帮帮我,谢谢
我是用C#的,数据库是access,在数据库里有两张表,除了ID字段,其他的字段都一样,我想实现在点击button的时候把table1的所有内容(除ID字段的内容外)全部插入到table2相应的字段里面,格式和table1一样,请问该怎么实现呢?
比如,table1里:id设置的是自动编号
            id       name       price
            1         www         50
            2         ccc         60
点击button后实现table2里:id是自动编号,所以有可能不一样
          id         name       price
          x             www         50
          x             ccc         60
等于就是把table1里的东西除ID外全部复制到table2里去了,请问该怎么解决呢?谢谢大家

------解决方案--------------------
insert into table2(name,price) select name,pricefrom table1
------解决方案--------------------
直接取需要的字段插入到新表中就好了
------解决方案--------------------
insert A( t_date,type_code,con_code) select t_date,type_code,con_code from B
------解决方案--------------------
insert into table2(name,price) select name,price from table1
方法正确~

------解决方案--------------------
insert into table2(name,price) select name,price from table1
-------------------------
up
------解决方案--------------------
insert into table2(name,price) select name,price from table1
正解
------解决方案--------------------
insert into table2(name,price) select name,price from table1
没错
------解决方案--------------------
insert into table2(name,price) select name,price from table1
up