You should use it in every where there maybe an error occurs.for example:
user input two number A and B, if you use A/B then you should add a try catch for the B=0 situation.another example:int custid=0;
if (Request.QueryString["CustID"] != null)
{
try
{
custid = int.Parse( Request.QueryString["CustID"].ToString() );
}
catch
{
}
}Because you cann't make sure the passed in custid always be a number.etc.
user input two number A and B, if you use A/B then you should add a try catch for the B=0 situation.another example:int custid=0;
if (Request.QueryString["CustID"] != null)
{
try
{
custid = int.Parse( Request.QueryString["CustID"].ToString() );
}
catch
{
}
}Because you cann't make sure the passed in custid always be a number.etc.
解决方案 »
- 唉,一句话也出错了
- 关于二级联动无刷新
- 关于类作为参数传递的问题
- my97的返回值问题
- 帮忙看一下这个错误怎么解决?读取网卡时出错
- web程序如何获得局域网中所有可用的打印机名字?
- treeview控件的treenodesrc的问题
- win 2000 Server SP4 的操作系统,安装过诺顿杀毒软件和visual studio 6.0 以后安装.net framework 1.1 安装不上
- 我在页面中有两个按钮,一个是上传的按钮,我一提交总显示那些需要验证的控件出错,不让我提交怎么办呀!
- OleDbDataReader使用错误,请高手指教!
- 无法从web服务器获取项目文件,什么原因?
- 数据库中有文件对应的类型吗?
能不能写下具体捕捉什么错误?让大家看看嘛。to spring_ok(SpringDotNet)
能不能再举一些其他常用的错误?
象“一切肯能出错的地方都可以用Try...catch 捕捉”这种话说了和没说一样。
try
{
sqlCommand.ExecuteNonQuery();
}
catch
{
Message.Text = " ... ";
Message.Style["color"] = "red";
}
如果可以预料的错误,尽量避免错误捕捉,如 if(obj!=null)to buaawjh(神之恋语) :需要系统释放资源,一般用finally
如果可以预料的错误,尽量避免错误捕捉,如 if(obj!=null)