本帖最后由 zts107 于 2011-11-12 14:14:50 编辑

解决方案 »

  1.   

    cn.Open strCn
    '清空表记录
    cn.execute "truncate table table1"
    '循环增加记录
    For row = Me.TextBox1.Value To Me.TextBox2.Value
      strSQL = "insert into table1(供应商代码,物料代码,单位,不含税单价,供应商名称,物料名称) values ( '" & Sheet3.Cells(row, 1) & "','" & Sheet3.Cells(row, 2) & "','" & Sheet3.Cells(row, 3) & "','" & Sheet3.Cells(row, 4) & "','" & Sheet3.Cells(row, 5) & "','" & Sheet3.Cells(row, 6) & "')"
    cn.execute strSQL
    Next row
    cn.execute " exec 存储过程名 "
    cn.Close
      

  2.   

    谢谢leftie,
    不过运行时要点三次btn_Click()按钮才会生效,为什么呢。。有点晕。难道是我的存储过程有问题?
      

  3.   

    大至环境描述一下:
    1,用excel行记录插入到某一数据库的表table1,这一步已正常。代码如下:
    cn.Open strCn
    '清空表记录
    cn.execute "truncate table table1"
    '循环增加记录
    For row = Me.TextBox1.Value To Me.TextBox2.Value
      strSQL = "insert into table1(供应商代码,物料代码,单位,不含税单价,供应商名称,物料名称) values ( '" & Sheet3.Cells(row, 1) & "','" & Sheet3.Cells(row, 2) & "','" & Sheet3.Cells(row, 3) & "','" & Sheet3.Cells(row, 4) & "','" & Sheet3.Cells(row, 5) & "','" & Sheet3.Cells(row, 6) & "')"
    cn.execute strSQL
    Next row
    cn.execute " exec 存储过程名 "
    cn.Close2.再用table1中的字段"不含税单价"去关联并更新其它的表。
    写了一个用于更新的的存储过程,代码如下:
    update icstockbtry 
    set icstockbtry.fprice=b.不含税单价,fauxprice=(fprice/1.17),famount=(fqty*fauxprice)
    from icstockbtry a, table1 b, icstockbill c,t_icitem d,t_supplier e
    where c.fdate=b.入库日期 and b.物料代码=d.fnumber and b.供应商代码=e.fnumber and c.ftrantype=1 and a.finterid=c.finterid可是问题来了,为什么要在确定三次Button按钮icstockbtry表才会更新呢?头大了!