Foxtable(狐表)用户栏目专家坐堂 → 存储过程不返回记录


  共有2533人关注过本帖树形打印复制链接

主题:存储过程不返回记录

帅哥哟,离线,有人找我吗?
whwsyscom
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:370 积分:4106 威望:0 精华:0 注册:2012/10/6 8:31:00
存储过程不返回记录  发帖心情 Post By: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

 回到顶部