Hi

I am quite new to C#/Asp.Net and having some difficulties using error
handling in a Class.

Currently there is no error handling in the Class
- The Class is compiled to a DLL and used to execute an SQL stored
procedure
- This class is then called from an ASPX page

The question is, how do I add exeption handling to the Class which
will return an error or success message to the ASPX page where it was
called.

Any help is greatley appreciated

Thanks
James

Class Code:
    public class sqltest //
    {

        public sqltest(string a, string b)
        {

            SqlConnection sqlConn = new SqlConnection
(ConfigurationSettings.AppSettings["TestDatabaseConnection"]);
            SqlCommand sqlCmd = new SqlCommand("TestStoredProcedure",
sqlConn);
            sqlCmd.CommandType = CommandType.StoredProcedure;

            SqlParameter sqlParam = null;

            sqlParam = sqlCmd.Parameters.Add("@FirstValue",
SqlDbType.VarChar, 50);
            sqlParam.Value = a;

            sqlParam = sqlCmd.Parameters.Add("@SecondValue",
SqlDbType.VarChar, 50);
            sqlParam.Value = b;

            sqlConn.Open();

            sqlCmd.ExecuteNonQuery();

            sqlConn.Close();
        }
    }

ASPX.CS Code
    protected void Button1_Click(object sender, EventArgs e)
    {
        sqltest callCMD = new sqltest(TextBox1.Text, TextBox2.Text);
    }



Reply via email to