Abdalla Elawad

Abdalla Elawad

  • 1.2k
  • 1k
  • 181.9k

String or binary data would be truncated.

Jun 4 2016 3:42 AM
try
{
SqlCommand cmd = new SqlCommand("M_Update", Conn);
cmd.Parameters.Add("@CarNo", SqlDbType.Char).Value = (DropDownList1.SelectedValue);
cmd.Parameters.Add("@TeamNo", SqlDbType.BigInt).Value = TextBox1.Text.Trim();
cmd.Parameters.Add("@Customers", SqlDbType.NVarChar).Value = TextBox5.Text.Trim();
cmd.Parameters.Add("@DriverName", SqlDbType.NVarChar).Value = (DropDownList8.SelectedValue);
cmd.Parameters.Add("@First_Supervisor", SqlDbType.NVarChar).Value = (DropDownList9.SelectedValue);
cmd.Parameters.Add("@Second_Supervisor", SqlDbType.NVarChar).Value = (DropDownList10.SelectedValue);
cmd.Parameters.Add("@ServiceType", SqlDbType.NVarChar).Value = (DropDownList2.SelectedValue);
cmd.Parameters.Add("@BankName", SqlDbType.NVarChar).Value = (DropDownList3.SelectedValue);
cmd.Parameters.Add("@Region", SqlDbType.NVarChar).Value = (DropDownList4.SelectedValue);
cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = (DropDownList5.SelectedValue);
cmd.Parameters.Add("@PlanStartDate", SqlDbType.Date).Value = TextBox6.Text.Trim();
cmd.Parameters.Add("@Recycle_Date", SqlDbType.Date).Value = TextBox7.Text.Trim();
cmd.Parameters.Add("@Case_Option", SqlDbType.NVarChar).Value = (DropDownList6.SelectedValue);
cmd.Parameters.Add("@AbsenseName", SqlDbType.NVarChar).Value = (DropDownList7.SelectedValue);
cmd.Parameters.Add("@Responsible_1", SqlDbType.NVarChar).Value = TextBox14.Text.Trim();
cmd.Parameters.Add("@Responsible_2", SqlDbType.NVarChar).Value = TextBox15.Text.Trim();
cmd.Parameters.Add("@AlterSuper_1", SqlDbType.NVarChar).Value = TextBox12.Text.Trim();
cmd.Parameters.Add("@AlterSuper_2", SqlDbType.NVarChar).Value = TextBox13.Text.Trim();
cmd.Parameters.Add("@EmpAlterDate", SqlDbType.Date).Value = TextBox16.Text.Trim();
cmd.Parameters.Add("@NewRecycleDate", SqlDbType.Date).Value = TextBox17.Text.Trim();
cmd.Parameters.Add("@OperationDate", SqlDbType.Date).Value = TextBox6.Text.Trim();
cmd.CommandType = CommandType.StoredProcedure;
Conn.Open();
cmd.ExecuteNonQuery();
Conn.Close();
TextBox1.Text = "";
//TextBox2.Text = "";
//TextBox4.Text = "";
TextBox5.Text = "";
//TextBox3.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox12.Text = "";
TextBox13.Text = "";
TextBox14.Text = "";
TextBox15.Text = "";
TextBox16.Text = "";
TextBox17.Text = "";
Msglbl.Visible = true;
Msglbl.Text = "updated data";
}
catch
{
Msglbl.Text = " Not Update";
}
}

Answers (3)