How to Return Exception from Function in class
<p>i am creating a function <code>createFolding</code> in my class named <code>clsFolding</code>. i am inserting some values in database through this function <code>createFolding</code>. so i am returning <code>int status_id</code> from function back (1 if Ok, 0 if error). i also want to return exception message from function if there is error (if <code>status_id =0</code>) but i don't know how to return multiple values from my function back. here is my code that i have done in my class <code>clsFolding</code> </p>

<pre><code>public class clsFolding
    {
        public static string ConStr = ConfigurationManager.ConnectionStrings["FazalConstructions.Properties.Settings.ConnString"].ConnectionString;
        public static SqlConnection con;
        public static SqlCommand cmd = new SqlCommand();
        public static int status_id;
        public static Exception ex;

        public static int createFolding(int id, string name, int qty, string narration, DateTime dt)
        {
            try
            {
                con = new SqlConnection(ConStr);
                con.Open();
                cmd = new SqlCommand("INSERT INTO tblFolding(FoldingID, Name,Quantity,Narration,DateTime)VALUES(@id, @name, @qty, @narration,@dt)", con);

                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@qty", qty);
                cmd.Parameters.AddWithValue("@narration", narration);
                cmd.Parameters.AddWithValue("@dt", dt);
                cmd.ExecuteNonQuery();

                status_id = 1;
                return status_id;
            }
            catch (Exception ex)
            {
                status_id = 0;
               return status_id;
            }
</code></pre>

<p>here is my code that i used in my form to get data from class</p>

<pre><code>clsStockManagement.updateStock(int.Parse(TransactionID.Text), int.Parse(projectID.Text), int.Parse(cbItem.SelectedValue.ToString()), int.Parse(tbQty.Text), DateTimee.Value);
            if (clsStockManagement.status_id==1)
            {
                MessageBox.Show("Process Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);


            }
            else if (clsStockManagement.status_id==0)
            {
                 MessageBox.Show("Process UnSuccessful", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
            }
</code></pre>