Catch is used just to  trap your error..
you may want to do something like

catch (Exception ex)
                    {
                        throw new Exception(ex.Message);


                    }

hopefully you will get enough detail in your error message in the event that
you have one



On Thu, Oct 7, 2010 at 12:48 PM, Stephen Russell <[email protected]>wrote:

> // answers in line
>
> On Thu, Oct 7, 2010 at 6:00 AM, Gourav <[email protected]> wrote:
> > Hi All ,
> >   I just make a connection class in App_code .But i didn't know what
> > i write in catch block for Error exception.Any body can tell me ??
> > i'll wait for reply.....
> > and one more thind what is differance between
> > catch and  catch (Exception ex)....means in which condition we use it
> > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> > public static void ExecuteNonQuery(string query)
> -----------------
>
> Does it matter at all?  This is a void, thus you don't care what
> happens in the process.
>
> Why not return a string?
>
> >    {
> >        SqlConnection Scon = new
> >
> SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
> >        Scon.Open();
>
> StringOhNo;
>
> >        try
> >        {
> >            SqlCommand cmd = new SqlCommand();
> >            cmd = Scon.CreateCommand();
> >            cmd.CommandType = CommandType.Text;
> >            cmd.CommandText = query;
>
>
> OhNo = cmd.ExecuteNonQuery() > 0  ? "cool" : "no records manipulated";
> >
> >        }
> >        catch (Exception ex)
> >        {
>                OhNo = ex.Message;
>
> >        }
> >
> >        finally
> >        {
> >            Scon.Close();
> >        }
>
> return OhNo;
>
>
> >    }
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
>
> --
> Stephen Russell
>
> Sr. Production Systems Programmer
> CIMSgts
>
> 901.246-0159 cell
>



-- 
Keidrick Pettaway

http://kpettaway.com

Reply via email to