您的位置:程序门 -> vb -> 基础类



vb调用存储过程


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vb调用存储过程
发表于:2007-01-02 11:02:55 楼主
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没有打开?
发表于:2007-01-02 13:41:161楼 得分:0
up


快速检索

最新资讯
热门点击