Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET SQL-Server
protected void btnSignIn_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtAdminID.Text.Trim() == "")
            {
                lblMessage.Text = "Enter Admin Id!";
                txtAdminID.Focus();
                return;
            }
            else if (txtPassword.Text.Trim() == "")
            {
                lblMessage.Text = "Enter Password!";
                txtPassword.Focus();
                return;
            }
            else
            {
                
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["amms"].ConnectionString);
                con.Open();
                cmd = new SqlCommand();
                cmd.Connection = con;
 
                             
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "CheckUserLogin";
                cmd.Parameters.AddWithValue("@LoginId", txtAdminID.Text.Trim());
                cmd.Parameters.AddWithValue("@Passwd", txtPassword.Text.Trim());
                cmd.Parameters.AddWithValue("@abc", 0).Direction = ParameterDirection.InputOutput;
                
                cmd.ExecuteNonQuery();
                con.Close();
 
                if ((int)cmd.Parameters["@abc"].Value == 0)
                {
                    lblMessage.Text = "Invalid Admin Id or Password!";
                    txtAdminID.Focus();
                    return;
                }
                else
                {
                    Response.Redirect("MemberRegistration.aspx");
                }
            }
        }
        catch (Exception ex)
        {
            con.Close();
            lblMessage.Text = ex.Message;
        }
Posted 29-Sep-12 7:31am
Edited 29-Sep-12 7:35am
JF201553.2K
v2
Comments
Marcus Kramer at 29-Sep-12 13:55pm
   
What didn't work. Perhaps you should add the exception you get to your question so that we know what is failing. There are so many places where something can go wrong in this code that it would take a miracle for someone to figure it out for you without that exception message.
ridoy at 29-Sep-12 13:56pm
   
you need to tell what error occurs?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

this error occurred due to line
cmd.Parameters.AddWithValue("@abc", 0).Direction = ParameterDirection.InputOutput;
 

can u explain about your procedure ?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

this error occurred due to line
cmd.Parameters.AddWithValue("@abc", 0).Direction = ParameterDirection.InputOutput;
can u explain about your procedure ?
 
i think u r not declaring @abc as output parameter in procedure that is why error occurred .
 
Your procedure should be like this :
 
alter procedure TestProject (
@LoginId varchar(20),
@UsrPsw Varchar(20),
@abc int output -- Declare as output parameter )
as
begin
 
insert into tableProject values(@UsrName,@UsrPsw)
select @abc =1 -- just for example .

end
 

 
I hope this will help u .
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,805
1 OriginalGriff 6,696
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,792


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100