When I execute the code this error message occurs:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Companyregister";
cmd.Parameters.AddWithValue("@Company_name", txtname.Text);
cmd.Parameters.AddWithValue("@Register_no", txtreg_no.Text);
cmd.Parameters.AddWithValue("@Type", DropDownList1.Text);
cmd.Parameters.AddWithValue("@Address", txtadrs.Text);
cmd.Parameters.AddWithValue("@Email", txtemail.Text);
cmd.Parameters.AddWithValue("@Contact_no", txtphone.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Write("Register succesful");
}
Error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: String or binary data would be truncated.
The statement has been terminated.
What is wrong in my code or my stored procedure that causes this exception and how do I solve that?