but now am coming back with a question in sql server.
i have a problem of how i can display a message from database to the interface in asp.net
i can do this when it is about an error but i want to display a message telling to the student
that the assignment date is approching in 3 days how can do this? i can print a message but i do not know
how i can in visual studio because it will not be as an error . THANK YOU SO MUCH!
HERE BELOW THIS IS MY CODE
---------------------------------------------
USE [DBOACS]
GO
/****** Object: StoredProcedure [dbo].[assgnmentcheckDeadLlinePeriod] Script Date: 07/05/2013 14:04:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO -- THOSE THE FIELD IN THE TABLE STUDENTSENTASSIGNMENT DateSent is the date on which the student will send it
ALTER procedure [dbo].[assgnmentcheckDeadLlinePeriod](@CourseCode nvarchar(50),
@AssignmentDescription nvarchar(400),@AssignmentFileName nvarchar(80),@assignmentFilePath nvarchar(550), @DateSent datetime,
@StudentId nvarchar(50))
as
declare @DATEEXPRE datetime
set @DATEEXPRE = (select max(AssignmentDeadLineDate) from LecturerAssignmentTable where AssignmentDescription = @AssignmentDescription)
if (@DATEEXPRE>@DateSent)
begin
INSERT INTO [DBOACS].[dbo].[studentSentAssignmentsTBL]
VALUES (@CourseCode,@AssignmentDescription,@AssignmentFileName,@assignmentFilePath,@DateSent,@StudentId)
end
else
begin
raiserror('Sorry you are too late to send this assignment!',16,1)
end
---- changing date
--
--declare @days int
--set @days=datediff(day,getdate(),'6/25/2013 12:00:00 AM')
-- if(@days=3)
--begin
--raiserror('your ass is remainning with 3 days',16,1)
--end
----end chaking dates
-- else
-- begin
----raiserror('Sorry you are late to send this assignment',16,1)
-- END
--exec assgnmentcheckDeadLinTimes 'INSY 765','testass','df','','7/19/2013','12121'
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Jul 5, 2013, 11:03 PM
declare @IsError bit;
SET @IsError=0
SET @IsError=1
SELECT @IsError as IsErrorOccured
In your Visual Studio use .ExecuteScalar instead of ExecuteNonQuery like
var result=Convert.ToBoolean(cmd.ExecuteScalar());
if(result)
{
Response.Write(Sorry you are too late to send this assignment!);
}
You need to use RAISEERROR only if you want handle any error handling in SQL. Refer the below link
http://msdn.microsoft.com/en-us/library/ms178592(v=sql.90).aspx
Regards,
Iftikar
modeste modestePosted Jul 5, 2013, 12:54 PM
Iftikar HussainPosted Jul 5, 2013, 11:38 AM
Which version of sql you are using. If you are using 2008 then you can have
TRY and CATCH and same in your aspx code
http://msdn.microsoft.com/en-us/library/ms175976.aspx
Regards,
Iftikar