Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
my code is
C#
protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            SqlConnection vcon = new SqlConnection(ConfigurationManager.ConnectionStrings["surendra"].ToString());

            vcon.Open();
            SqlCommand vcmd = new SqlCommand();
            vcmd.Connection = vcon;
            vcmd.CommandType = CommandType.StoredProcedure;
            vcmd.CommandText = "register_sp ";
            SqlParameter sp1 = new SqlParameter("@emailid", SqlDbType.VarChar, 100);
            sp1.Direction = ParameterDirection.Input;
            sp1.Value = Txteid.Text;
            vcmd.Parameters.Add(sp1);
            SqlParameter sp2 = new SqlParameter("@password", SqlDbType.Int);
            sp2.Direction = ParameterDirection.InputOutput;
            sp2.Value = Txtpwd.Text;
            vcmd.Parameters.Add(sp2);
            SqlParameter sp3 = new SqlParameter("@firstname", SqlDbType.VarChar, 100);
            sp3.Direction = ParameterDirection.Input;
            sp3.Value = txtfname.Text;
            vcmd.Parameters.Add(sp3);
            SqlParameter sp4 = new SqlParameter("@lastname", SqlDbType.VarChar, 100);
            sp4.Direction = ParameterDirection.Input;
            sp4.Value = Txtlname.Text;
            vcmd.Parameters.Add(sp4);
            vcmd.ExecuteNonQuery();
            Response.Write("http://www.facebook.com");
            vcon.Close();
        }
       catch(Exception ex)
        {

            Response.Write(ex.Message);
       }

my database is
SQL
ALTER procedure [dbo].[register_sp]
@emailid varchar(100),@password int,@firstname varchar(100),@lastname varchar(100)
as
insert into  Users(emailid,Password,firstname,lastname) values (@emailid,@password,@firstname,@lastname)
select * from users
Posted
Updated 7-Aug-13 9:55am
v4
Comments
Richard C Bishop 7-Aug-13 15:30pm    
Do you have a question?
[no name] 7-Aug-13 15:32pm    
Txtpwd.Text is a string not an int.

Why do you seem to think that all passwords will be numbers?
And integers at that?
You set your parameter as an into, and then pass it a user entered string... So even if it was supposed to be numeric, you don't check, so any user input error will crash the app...
 
Share this answer
 
Instead of integer try varchar for password field.
 
Share this answer
 
Do you want all users to enter numeric password?? even if it is so ,You should use

Convert.ToInt32(txtpwd.Text);
 
Share this answer
 
just change
sp2.Value = Txtpwd.Text;
to
sp2.Value =Convert.ToInt16(txtpwd.Text);(or Convert.ToInt32(txtpwd.Text);)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900