以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  存储过程不返回记录  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=58258)

--  作者:whwsyscom
--  发布时间:2014/10/14 16:46:00
--  存储过程不返回记录

ALTER PROCEDURE [dbo].[化验对比]
-- Add the parameters for the stored procedure here
 @rq [datetime]
AS

set @rq=\'2014-10-11\'
declare @table table(
[车间] [nvarchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[工区] [nvarchar](4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[槽号] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[日期] [datetime] NOT NULL,
    [启动日期] [datetime] NOT NULL,
[Fe] [real] NULL,
[Si] [real] NULL,
[铁变化] [real] NULL,
[硅变化] [real] NULL,
[化铁量] [real] NULL,
[化硅量] [real] NULL
)
insert into 
 @table([车间],[工区],[槽号],[日期],[启动日期],[Fe],[Si])
  (
   select[车间],[工区],[槽号],[日期],[启动日期],[Fe],[Si] from 化验单 where [日期]=@rq
  )

declare @tableqt table(
[车间] [nvarchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[工区] [nvarchar](4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[槽号] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[日期] [datetime] NOT NULL,
    [启动日期] [datetime] NOT NULL,
[Fe] [real] NULL,
[Si] [real] NULL,
[铁变化] [real] NULL,
[硅变化] [real] NULL,
[化铁量] [real] NULL,
[化硅量] [real] NULL
)
insert into 
 @tableqt([车间],[工区],[槽号],[日期],[启动日期],[Fe],[Si])
  (
   select[车间],[工区],[槽号],[日期],[启动日期],[Fe],[Si] from 化验单 where [日期]=(select dateadd(d,-1,@rq))
  )
set nocount on
select 
 a.槽号, round(a.Fe-b.Fe,3)*1000 as 铁变化,round((a.Fe-b.Fe)*150+(a.fe-0.15)*17.5,0) as 化铁量,a.fe,b.fe as 铁b
from 
  @table a 
left join 
 @tableqt b 
on b.槽号=a.槽号

return 
这是我写的存储过程,在SQL中执行能返回记录
在foxtable中执行不返回记录是什么原因?

Dim rq As Date
rq="2014-10-11"
Dim cmd As new SQLCommand
Dim conn As String
c
cmd.ConnectionName=conn
cmd.CommandText= "Exec 化验对比 \'2014-10-11\'"
\'messagebox.Show(cmd.CommandText)
Dim t As DataTable 
t= cmd.ExecuteReader
messagebox.show(t.DataRows.Count)
For Each dr As DataRow In t.DataRows
output.show(dr("槽号"))
Next

--  作者:有点甜
--  发布时间:2014/10/14 16:50:00
--  

 参考这里

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=42263&replyID=&skin=1