Try Catch Error for namespace

Posted by Vanchi050585 under Regular Expressions on 3/21/2011 | Points: 10 | Views : 2570 | Status : [Member] | Replies : 3
Hi Everybody,

when i am trying to write try catch block the following error was occured.
Error:
System.Web.TraceContext' does not contain a definition for 'TraceError' and no extension method 'TraceError' accepting a first argument of type 'System.Web.TraceContext' could be found (are you missing a using directive or an assembly reference?)

Coding:
try
{
cmd.Parameters.Add("@Category", SqlDbType.VarChar).Value = ddlCategory.SelectedItem.ToString();
cmd.Parameters.Add("@Title", SqlDbType.VarChar).Value = txtTitle.Text;
cmd.Parameters.Add("@Descript", SqlDbType.VarChar).Value = txtDesc.Text;
cmd.Parameters.Add("@Link1", SqlDbType.VarChar).Value = txtLink1.Text;
cmd.Parameters.Add("@Link2", SqlDbType.VarChar).Value = txtLink2.Text;
cmd.Parameters.Add("@Author", SqlDbType.VarChar).Value = Username.ToString();
cmd.Parameters.Add("@Dateofpost", SqlDbType.DateTime).Value = System.DateTime.Today;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch (InvalidCastException ex)
{
Debug.Write(ex.Message);
}
catch (IndexOutOfRangeException ex)
{
Trace.TraceError(ex.Message);
}
catch (Exception ex)
{
throw ex;
}

if anybody knows please let me know

Thanks

Thanks
tvn



Responses

Posted by: Prabhakar on: 3/21/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi vanchi


i think u miss ur name spaces . . firstly added on web page

System.Web


add it now...

Best Regard's
Prabhakar

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Trace.TraceError is a class in System.Diagnostics namespace. So include this into your namespace list and build.

Thanks and Regards
Madhu

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsolvers on: 3/21/2011 [Member] Starter | Points: 25

Up
0
Down
Exactly!

Best Regards,

VG
www.TeacherJi.com

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response