|
CREATE PROCEDURE sp_compare AS
IF (select name from sysobjects where name='TAB_RESULT_FINACE')<>''
DROP TABLE TAB_RESULT_FINACE
SELECT 出庫類別, 出庫單號碼, [SO No#], 客戶編碼, 客戶名稱, 客户PO号, 擔當者,
[Invoice Date], 幣別, 金额, 狀態 INTO #TAB_ACCOUNT
FROM TAB_ACCOUNT WHERE (狀態 = N'未開票') OR (狀態 = N'開票中')
SELECT TAB_INVOICE.[客户编 号], TAB_INVOICE.[客户名 称],
TAB_INVOICE.[(期末余额)本币] AS 预收余额, sum(case when 金额 is null then 0 else 金额 end)
AS 开票金额, (sum([(期末余额)本币])+sum(case when 金额 is null then 0 else 金额 end)) as 预付款余额
INTO TAB_RESULT_FINACE
FROM TAB_INVOICE LEFT OUTER JOIN #TAB_ACCOUNT ON
TAB_INVOICE.[客户编 号] = #TAB_ACCOUNT.客戶編碼
GROUP BY TAB_INVOICE.[客户编 号], TAB_INVOICE.[客户名 称],TAB_INVOICE.[(期末余额)本币]
SELECT TAB_RESULT_FINACE.[客户编 号], TAB_RESULT_FINACE.[客户名 称],
TAB_RESULT_FINACE.预付款余额 AS 'U8 预付款余额', SUM(TAB_RESULT.预付款余额) AS 'CS预付款余额',
(CASE WHEN TAB_RESULT_FINACE.预付款余额=SUM(TAB_RESULT.预付款余额) THEN 'TRUE' ELSE 'FALSE' END) AS '比较值'
FROM TAB_RESULT_FINACE LEFT OUTER JOIN
TAB_RESULT ON TAB_RESULT_FINACE.[客户编 号] = TAB_RESULT.[客户编 号]
GROUP BY TAB_RESULT_FINACE.[客户编 号], TAB_RESULT_FINACE.[客户名 称],TAB_RESULT_FINACE.预付款余额
GO
我的存储过程是这样的,我现在发现是在VB中执行存储过程有问题,存储过程本身没问题,我在查询分析器中都调用过,可是在VB中调用就是不行,请帮我看一下是什么问题!
Set oRst = New ADODB.Recordset
cn1.CursorLocation = adUseClient
Set oRst = cn1.Execute("exec sp_compare")
spdDetail.MaxRows = 0
Do While Not oRst.EOF
spdDetail.MaxRows = spdDetail.MaxRows + 1
spdDetail.Row = spdDetail.MaxRows
spdDetail.SetText 1, spdDetail.Row, oRst.Fields(0)
spdDetail.SetText 2, spdDetail.Row, oRst.Fields(1)
spdDetail.SetText 3, spdDetail.Row, oRst.Fields(2)
spdDetail.SetText 4, spdDetail.Row, oRst.Fields(3)
spdDetail.SetText 5, spdDetail.Row, oRst.Fields(4)
oRst.MoveNext
Loop
我已经调用了存储过程,我要把执行存储过程SELECT的数据读入表格控件,可是老是说数据集对象ORST没有打开?
|
|