这只是 excute 执行的SQL语句改变,你直接付给它不就行了/

解决方案 »

  1.   

    rs.open "select * from 表 where id='" & id & "'"
      

  2.   

    cn.excute "delete from B"
    cn.excute "insert into B select 字段1,字段2,... From A Where id='"& 变量 &"'"
      

  3.   

    步骤如下:
     1.清空B表
       strsql ="delete from B表"
       cn.Execute strsql
     2.得到A表数据并填充B表
       strsql ="select 要检索字段 from A表 where 字段a ='" & 变量a & "'"
       '如果字段a是数字类型可写成这样   字段a =" & 变量a 
       set re = cn.Execute(strsql)
       if not(re.eof or re.bof) then
          re.movefrist
          do until re.eof
             strsql = "insert into 表B (字段列表)values (re(0),re(1)...)"
             cn.Execute strsql
             re.movenext
          loop
          re.close
          set re = nothing 
       end if
      

  4.   

    sql1="drop table B"
    sql2="select * into B from A where 条件"
    Conn.execute sql1
    conn.execute sql2
      

  5.   

    楼上解释得很清楚了!
    不过第二条逐个记录复制太慢,可以这样:
    strsql = "insert into 表B (col1, col2...) SELECT col1, col2... FROM 表B WHERE 条件语句这样就可以把符合条件的所有记录都复制了
      

  6.   

    例如把combo.text的植作为  select ...where 的条件该怎么实现
    我这样做ADODC1.recordsoure="insert into b select * from b where 产品名称=combo1.text and 产品编号=combo2.text"但B表的数据没有变
      

  7.   

    前面大家说得很详细了,照做应该没问题。我的意见:
    1 Combo.Text 的值应该作为变量传入SQL语句。
    ADODC1.recordsoure="insert into b select * from b where 产品名称= " & combo1.text & "and 产品编号= " & combo2.text2 string型数据在SQL语句里要由单引号包起来。
    如产品名称是string类型的话要写成
    "... where 产品名称 = '" & combo1.text & "' and ..." 3 SQL语句要一步一步执行,即 delete 、insert 、select 分开EXCUTE
      

  8.   

    假设表B中有字段f1、f2、f3、f4,表A中有字段g1、g2、g3、g4,要把表了B中的数据插入表A,必须要把两表的字段对应好,也就是插入相应的字段中:strsql = "insert into 表B (f1,f2,f3,f4) select g1,g2,g3,g4 FROM 表B WHERE 产品编号 ='" & combo2.text & "'"为什么你既要查产品编号又要查产品名称?你的产品编号不是唯一的吗?
      

  9.   

    ADODC1.recordsoure="insert into b select * from b where 产品名称=combo1.text and 产品编号=combo2.text"你的这句也错了,这个怎么可以做为数据源呢?
    试试以下的代码,保证成功:Dim cmS As ADODB.Command
    dim strsql as stringSet cmS = New ADODB.Command
    cmS.ActiveConnection = cnn
    cmS.CommandType = adCmdTextstrsql = "insert into 表B (f1,f2,f3,f4) select g1,g2,g3,g4 FROM 表B WHERE 产品编号 ='" & combo2.text & "'"
    cmS.CommandText = strsql
    cmS.Executecnn是连接数据库的语句,ADODB.Connection,这个不会也叫我给你写吧?