Getting Fatal Error when using MySQL with C#

this is the code i am using 

public static void updateobject(class object,string id)
{
    string sql = "UPDATE table SET Name = @name WHERE ID=@id";

    MySqlConnection con = GetConnection();

    MySqlCommand cmd = new MySqlCommand(sql, con);
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.Add("@name", MySqlDbType.String).Value = object.Name;

    try
    {
        cmd.ExecuteNonQuery();
    }
    catch (MySqlException ex)
    {
        MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    con.Close();
}

Not sure, when this function is called, it is terminating the code with fatal error. No specific error generated but not able to execute too.