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
rajeev kumar
NA
141
14.2k
why ExecuteScalar allways returing 0 ?
Jun 30 2017 5:44 AM
hello sir,
my sp working fine in sql but when i m calling it my c# it allways returing 0 .
please help me.
here is my sql sp
CREATE PROCEDURE test
@Email as varchar(50),
@Passwords as varchar(50)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Exists INT
IF EXISTS(SELECT UserID,Email,Passwords,f_name,l_name FROM tbl_Register WHERE Email=@Email AND Passwords=@Passwords)
BEGIN
SET @Exists = 0
END
ELSE
BEGIN
SET @Exists = 1
END
RETURN @Exists
END
and here is my c# methods
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string User_login(usrlogin ulog) // user login functions
{
int Exists= 0;
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["con"].ToString());
SqlCommand com = new SqlCommand("test", con);
com.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("Email", ulog.Email);
SqlParameter p2 = new SqlParameter("Passwords", ulog.Passwords);
com.Parameters.Add(p1);
com.Parameters.Add(p2);
con.Open();
Exists = Convert.ToInt32(com.ExecuteScalar());
string IsValidate = string.Empty;
switch (Exists)
{
case 1:
IsValidate = "go";
break;
case 0:
IsValidate = "iup";
break;
}
return IsValidate;
}
Reply
Answers (
1
)
How to create dynamic word document in .Net Core (MVC)
How can we work in .Net Windows application with mariadb .?