Click here to Skip to main content
12,947,643 members (62,320 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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
Updated 29-Sep-12 7:35am
JF201555.3K
v2
Comments
Marcus Kramer 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 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
Top Experts
Last 24hrsThis month
OriginalGriff 5,134
CHill60 3,275
Maciej Los 2,563
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2017
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