找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 2804|回复: 3

[求助] 调用子件用途表的存储过程,运行很慢的原因?

[复制链接]
发表于 2015-12-22 18:05:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
VBA代码
  1. Sub 按钮1_单击()
  2. Dim conn As New ADODB.Connection
  3. Dim rst As ADODB.Recordset
  4. Dim constr As String
  5. Dim sql As String
  6. Dim bm As String
  7. Dim i, j

  8. On Error Resume Next

  9. constr = "Provider = SQLOLEDB;Data Source =JIN;Initial Catalog =UFDATA_666_2013;User ID =sa;Password =jin1668;"
  10. conn.Open (constr)

  11. Range("a6:j5000").ClearContents

  12. Randomize

  13. s = Int(Rnd * 10000 + 1000)
  14. ds = "NBUF_TmpReportA" & s

  15. bm = Trim(Range("b1"))
  16. If Len(bm) = 0 Then
  17. Exit Sub
  18. End If

  19. sql = "select a.cinvname,a.cinvstd,b.cComUnitName from inventory a left join ComputationUnit b on a.cComUnitCode =b.cComunitcode where a.cinvcode='" & bm & "'"

  20. Set rst = conn.Execute(sql)

  21. If rst.BOF = 0 Then
  22. Range("b2") = rst.Fields(0)
  23. Range("b3") = rst.Fields(1)
  24. Range("b4") = rst.Fields(2)
  25. Else
  26. MsgBox "不存在的存货编码!"
  27. Exit Sub
  28. End If

  29. Range("e1") = Time()

  30. [color=Red]sql = "exec Usp_BO_ExpandByComp 'and  1=1  And ((c.InvCode >= ''" & bm & "'') And (c.InvCode <= ''" & bm & "''))'," & " '" & "2099-12-04" & "', 0, 0, 3, 0, 0, 0,1,'', '','" & ds & " '"

  31. conn.Execute (sql)[/color]
  32. Range("e2") = Time()

  33. sql = "select 级别,子件行号,母件编码,母件名称,PItemSpec,母件计量单位,版本代号,版本说明,母件属性,基本用量 from " & ds

  34. Set rst = conn.Execute(sql)

  35. Range("e3") = Time()

  36. Cells(6, 1).CopyFromRecordset rst

  37. sql = "drop table " & ds
  38. conn.Execute (sql)

  39. rst.Close
  40. rst2.Close
  41. conn.Close

  42. Set rst = Nothing
  43. Set rst2 = Nothing
  44. Set conn = Nothing

  45. End Sub
复制代码

红色部门运行效率很慢,700多条母件记录要28秒,而用友系统只要2秒,,应该都是用的这个存储过程,这是那么回事,请高手指点?
发表于 2015-12-22 19:15:52 | 显示全部楼层
帮楼主顶一下!!!!
回复 点赞 拍砖

使用道具 举报

发表于 2015-12-23 10:25:12 | 显示全部楼层
帮顶一下,不明白
回复 点赞 拍砖

使用道具 举报

 楼主| 发表于 2015-12-24 15:38:15 | 显示全部楼层
帮顶一下,不明白
回复 点赞 拍砖

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-5-16 14:41 , Processed in 0.024556 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表