TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Monica Priyadharshini
NA
103
5k
error:not all code path returns a value
Sep 28 2017 2:00 AM
Hi,
i wrote a function in DAL layer which uses the stroreprocedure for returns the integer value but its ahowing an error.
my code is:
public int restrictionInCourse(int studentID,int CourseID)
{
int id;
SqlConnection con = new SqlConnection(constring);
SqlCommand cmd;
try
{
con.Open();
cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "spCourseRestrict";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@courseID", CourseID);
cmd.Parameters.Add("@StudentID", studentID);
id = Convert.ToInt32(cmd.ExecuteScalar());
return id;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
my storeprocedure is:
CREATE PROC spCourseRestrict
@StudentID int,
@courseID int
AS
Begin
DECLARE @Status int
SET @Status=0
IF(@courseID=116)
BEGIN
IF Exists(SELECT courseID FROM dbo.CourseRegistrationStd WHERE CourseID=111 and UserID=@studentID)
BEGIN
SET @Status=1
END
END
SELECT @Status
END
GO
cana anyone help me?
Reply
Answers (
4
)
Simple accordion for Sharepoint Summary Link
How to create any chart as a server side, without html in c#