Table structure is
userid int
fname varchar(50)
lname varchar(50)
Email varchar(50)
Phone decimal(18,2)
This is procedure
ALTER procedure [dbo].[AddUser]
@userid int,
@fname varchar(50),
@lname varchar(50),
@Email varchar(50),
@Phone decimal(18,2)
as
insert into UserInfo(Userid, Fname, Lname, Email, Phone)
values(@userid, @fname, @lname, @Email, @Phone)
This is my code....
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";
}
}
If I enter Phone no value max any eg. 233242342423 it gives error... please how to solve it?
decimal(18,2)anyway? Why does it need two decimal places? What about leading zeroes?decimalor any other numeric type for a phone number! Phone numbers are not "numbers", only a sequence of digits.