Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Table structre

userid int
fname varchar(50)
lname varchar(50)
Email varchar(50)
Phone varchar(50)







store procedure


SQL
ALTER procedure [dbo].[AddUser] @userid int,@fname varchar(50),@lname varchar(50),@Email varchar(50),@Phone varchar(50)
as
insert into UserInfo(Userid,Fname,Lname,Email,Phone) values(@userid,@fname,@lname,@Email,@Phone)




this is code


C#
protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["con1"]);
        try
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("AddUser",con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@userid",Int32.Parse(TextBox1.Text.Trim()));
            cmd.Parameters.AddWithValue("@fname",TextBox2.Text) ;
            cmd.Parameters.AddWithValue("@lname",TextBox3.Text) ;
            cmd.Parameters.AddWithValue("@Email",TextBox4.Text);
            cmd.Parameters.AddWithValue("@Phone",TextBox5.Text);
            cmd.ExecuteNonQuery();
            Label1.Text = "Record Has Been Added Successfully!";
        }
        catch (Exception en)
        {
            Label1.Text = "Retry to add";
        }
    }



getting error on when i insert phone value eg.9837747473...
Posted
Updated 29-Nov-13 3:05am
v2
Comments
I guess this is not for Phone number but for UserId. Please check.
phil.o 29-Nov-13 9:16am    
Which error? It's quite hard to guess; please improve your question and post the exception message.

1 solution

int data type has a range of −2,147,483,648 to +2,147,483,647, so 9837747473 will not fit.

Try changing your userid to bigint which is a long and use long.Parse(...)
 
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