Click here to Skip to main content
16,018,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

SQL
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)

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
Posted
Updated 9-Nov-14 10:00am
v4
Comments
Maciej Los 9-Nov-14 16:02pm    
And what's the issue?

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!
 
Share this answer
 
All you need is called stored procedure[^] with proper WHERE[^] statement, for example:
SQL
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


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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900