VBA中执行SQL存储过程的问题。 本帖最后由 zts107 于 2011-11-12 14:14:50 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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 strSQLNext rowcn.execute " exec 存储过程名 "cn.Close 谢谢leftie,不过运行时要点三次btn_Click()按钮才会生效,为什么呢。。有点晕。难道是我的存储过程有问题? 大至环境描述一下: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 strSQLNext rowcn.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 ewhere c.fdate=b.入库日期 and b.物料代码=d.fnumber and b.供应商代码=e.fnumber and c.ftrantype=1 and a.finterid=c.finterid可是问题来了,为什么要在确定三次Button按钮icstockbtry表才会更新呢?头大了! win7下安装摄像头的问题 有人做过录歌软件的开发么,想开发或者购买K8那样的录歌软件 很着急.接着在线等! 扬眉吐气!摒弃DVD,用自有产权EVD! 高手帮忙,需要系统分析文档 关于查找文本文件中的字符问题 帮忙解决一个问题!高分 我想用VB来做一个判断某个软件是否安装的程序。急请高手指点!高分,信誉100 对internet transfer控件,如何设置代理服务器用户名和密码?可不可设置? VB前景光明 错误:未发现数据源名称并且未指定默认驱动程序 在这个值得纪念的日子里,特此发帖恭贺及勉励本位面正在以及仍然将要奋斗的所有魔法师们, 祝你们节日快乐!!!!!!!
'清空表记录
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
不过运行时要点三次btn_Click()按钮才会生效,为什么呢。。有点晕。难道是我的存储过程有问题?
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表才会更新呢?头大了!