Carlos kambui

Carlos kambui

  • NA
  • 499
  • 124.6k

Conversion failed when converting the varchar value

May 30 2015 3:29 AM
 Conversion failed when converting the varchar value 'Hair dressing' to data type int. while 'Hair dressing is @course_name
public FeesstructureType SetFeesstructureTypeType(FeesstructureType tFeesstructureTypeid)
{
ReturnType returns = new ReturnType();
BuildConnstring();
using (SqlConnection conn = new SqlConnection(connstring))
{
using (SqlCommand Command = conn.CreateCommand())
{
conn.Open();
if (tFeesstructureTypeid.fees_id == 0)
{
Command.CommandText = "INSERT INTO fees_Structures VALUES (@term_id,@course_name,@fees_per_term,@exam_body,@student_id,@amount_paid,@balance,@date_of_payment)SET @fees_id = (SELECT SCOPE_IDENTITY())";
}
else
{
Command.CommandText = "UPDATE fees_Structures set term_id=@term_id,course_name=@course_name,fees_per_term=@fees_per_term,exam_body=@exam_body,student_id=@student_id,amount_paid=@amount_paid,balance=@balance,date_of_payment=@date_of_payment WHERE fees_id=@fees_id";
}
Command.Parameters.Add("@fees_id", SqlDbType.Int).Value = tFeesstructureTypeid.fees_id;
Command.Parameters.Add("@term_id", SqlDbType.Int).Value = tFeesstructureTypeid.term_id;
Command.Parameters.Add("@student_id", SqlDbType.Int).Value = tFeesstructureTypeid.student_id;
Command.Parameters.Add("@course_name", SqlDbType.VarChar, 50, ParameterDirection.Input.ToString()).Value = tFeesstructureTypeid.course_name;
Command.Parameters.Add("@exam_body", SqlDbType.VarChar, 50, ParameterDirection.Input.ToString()).Value = tFeesstructureTypeid.exam_body;
Command.Parameters.Add("@fees_per_term", SqlDbType.Money, 18, ParameterDirection.Input.ToString()).Value = tFeesstructureTypeid.fees_per_term;
Command.Parameters.Add("@amount_paid", SqlDbType.Money, 18, ParameterDirection.Input.ToString()).Value = tFeesstructureTypeid.amount_paid;
Command.Parameters.Add("@balance", SqlDbType.Money, 18, ParameterDirection.Input.ToString()).Value = tFeesstructureTypeid.balance;
Command.Parameters.Add("@date_of_payment", SqlDbType.DateTime ).Value = tFeesstructureTypeid.date_of_payment;
returns.return_code = Command.ExecuteNonQuery();
if
(returns.return_code == 1)
//returns.return_identity_code = Command.Parameters ("bill_unit_id");
returns.return_message = "Fees structure Succesfull";
return tFeesstructureTypeid;
}
}
}

Answers (2)