如何在Sql Server中显示结果 [英] How Do I Display Result In Sql Server

查看:500
本文介绍了如何在Sql Server中显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sql server 2008并希望在Asp.net前端显示结果。

我是一个新鲜的。请帮忙。谢谢。



I am using Sql server 2008 and want to display result in Asp.net Front End.
I am a fresher.Please help.Thanks in advance.

CREATE TABLE dbo.TestInsertState
(
  Id INT,
  AppliedFor INT,
  EntryDateTime DATETIME,
  bUpdate BIT
)

INSERT INTO dbo.TestInsertState(Id,AppliedFor,EntryDateTime,bUpdate) VALUES(1,7,'10/06/2014',0)
INSERT INTO dbo.TestInsertState(Id,AppliedFor,EntryDateTime,bUpdate) VALUES(2,5,'10/28/2014',0)
INSERT INTO dbo.TestInsertState(Id,AppliedFor,EntryDateTime,bUpdate) VALUES(3,6,'10/28/2014',0)
INSERT INTO dbo.TestInsertState(Id,AppliedFor,EntryDateTime,bUpdate) VALUES(4,7,'11/01/2014',0)



条件 :如果AppliedFor = 7且bUpdate = 0且DaysBeyond> 21个工作日(表示周一至周五)应显示。



如果AppliedFor<> 7和bUpdate = 0,则DaysBeyond> 7个工作日(表示周一至周五)应显示。



< b> 结果预期:


Condition : if AppliedFor=7 and bUpdate=0 and DaysBeyond>21 working days(means Monday to Friday) that should be displayed.

if AppliedFor <>7 and bUpdate=0 and DaysBeyond>7 working days(means Monday to Friday) that should be displayed.

Result Expected:

Id	AppliedFor	EntryDateTime	  bUpdate	DaysBeyond
1	   7	        06-Oct-2014	    No	           27
2	   5	        28- Oct -2014	    No	            9
3	   6	        28- Oct -2014	    No	            9

推荐答案

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是你想的很难!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!


你需要的只是存储过程 [ ^ ] WHERE [ ^ ]语句,例如:

All you need is called stored procedure[^] with proper WHERE[^] statement, for example:
CREATE PROCEDURE DataToDisplay
AS
BEGIN

    SELECT <Field_list>
    FROM TableName
    WHERE AppliedFor=7 and bUpdate=0 and DaysBeyond>21 
    UNION ALL
    --note: second Field_list must equal to the first one 
    SELECT <Field_list>
    FROM TableName
    WHERE AppliedFor<>7 and bUpdate=0 and DaysBeyond>7 

END





如何从代码后面调用它?请参阅:

如何:执行返回行的存储过程 [ ^ ]

演练:仅使用存储过程(C#) [ ^ ]

如何使用Visual Basic .NET在ASP.NET中调用SQL Server存储过程 [ ^ ]



How to call it from code behind? Please, see:
How to: Execute a Stored Procedure that Returns Rows[^]
Walkthrough: Using Only Stored Procedures (C#)[^]
How to call SQL Server stored procedures in ASP.NET by using Visual Basic .NET[^]


这篇关于如何在Sql Server中显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆