public void update(string str,string No)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
try
{
con.Open();
string sql = "update B_AttachmentType set Ratio='" + str + "' where AttachmentTypeID='" + No + "'"; SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
}
catch (Exception x)
{
throw (x);
}
}
如以上代码,加入了try catch ,但是遇到错误时页面还是报错,怎样是页面不报错,继续执行
catch里面怎样写代码?
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
try
{
con.Open();
string sql = "update B_AttachmentType set Ratio='" + str + "' where AttachmentTypeID='" + No + "'"; SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
}
catch (Exception x)
{
throw (x);
}
}
如以上代码,加入了try catch ,但是遇到错误时页面还是报错,怎样是页面不报错,继续执行
catch里面怎样写代码?
解决方案 »
- 网站错误日志记录了一个很诡异的问题!!!!!各位牛人来看看这是为什么!!标题一定要长!!!!
- 多线程 --- 求示例
- GridView中ImageField的图片显示问题!在线====
- 菜鸟关于ASP.NET中控件拖动问题
- .net ajax 框架 问题
- 在cs文件中如何输出dataset或者控件
- 复合控件和自定义控件
- 关于DataTable的问题.
- vs2008 怎么设置不给元素自动添加样式?
- 散分:我祝所有朋友们,五一玩的开心.顺便祝自己的网站今天上线: http://www.51https.com. 技术上还希望多多交流.
- 春节前最后一贴——求一个搜索框的高效算法或思路
- js如何判段该文本框是否存在光标
注释掉就不报错了
把 throw (x);去掉试下
改成
Response.Write(x);
试试这个行不行
Label1.Text = x.Message;
你抛出异常了。
你又把异常抛出来了
{
throw new DAOException(string.Format("修改信息时失败!"),ex);
}
{
lable1.text=err.message;///此处对错误信息任意处理,没throw就不出现大黄页了
}