我的sp如下:
create  proc [sp_fz_deta]
@ym varchar(8), --年月yyyy/mm
@empl_id varchar(4),--員工編號
@max_day int--當月的天數
as
declare @bdate varchar(10)
declare @i int
declare  @no int
declare @temp table ([year] varchar(2) ,[no] int)
 set @i=1
set @no=0
while @i<=@max_day
begin         
                 set @bdate=@ym+'/'+right('0000'+cast(@i  as varchar(2)),2)
 select @no=@no+count(*)   from t_brdl_fz_sour where flag='1' and empl_id=@empl_id and work_date=@bdate
 select @no=@no+count(*)   from t_bmad_fz_sour where flag='1' and  empl_id=@empl_id and work_date=@bdate
                 select @no=@no+count(*)   from t_mob_fz_sour where flag='1' and empl_id=@empl_id  and work_date=@bdate
                 insert into @temp values(@i,@no)
                 set @i=@i+1
                 set @no=0
              
 end
select * from @temp
如何在vb裡面得到 select * from @temp 的返回值???
我是這樣寫的
 Set iRecordset = Conn.Execute("exec sp_fz_deta '" & TxtDate.Text & "','" & TxtNo.Text & "','" & day & "'")
不行?

解决方案 »

  1.   

    问题出现在你的day上,day是int,所以要用"& day &",还有day要是int型是当月的天数!
      

  2.   

    使用ADODB.COMMAND对象的Parameters属性即可实现存储过程的操作,以下是asp应用中的例子:
    <%@ LANGUAGE="VBSCRIPT" %>
       <!--#include virtual="/ASPSAMP/SAMPLES/ADOVBS.INC"-->
       <HTML>
       <HEAD><TITLE>Place Document Title Here</TITLE></HEAD>
       <BODY>
       This first method queries the data source about the parameters
       of the stored procedure. This is the least efficient method of calling
       a stored procedure.<BR>
       <%
       Set cn = Server.CreateObject("ADODB.Connection")
       Set cmd = Server.CreateObject("ADODB.Command")
       cn.Open "data source name", "userid", "password"
       Set cmd.ActiveConnection = cn
       cmd.CommandText = "sp_test"
       cmd.CommandType = adCmdStoredProc
       ' Ask the server about the parameters for the stored proc
       cmd.Parameters.Refresh
       ' Assign a value to the 2nd parameter.
       ' Index of 0 represents first parameter.
       cmd.Parameters(1) = 11
       cmd.Execute
       %>
       Calling via method 1<BR>
       ReturnValue = <% Response.Write cmd.Parameters(0) %><P>