public SqlConnection Connect()
{
try
{
string Constr = @"server = (local);"+
"user id = sa;"+
"password = 9933;"+
"database = b2c;";
SqlConnection Conn = new SqlConnection(Constr);
return Conn;
}
catch(SqlException ex)
{
System.Web.HttpContext.Current.Session["messageerror"] = ex.Message;
throw;
} return null;
}
{
try
{
string Constr = @"server = (local);"+
"user id = sa;"+
"password = 9933;"+
"database = b2c;";
SqlConnection Conn = new SqlConnection(Constr);
return Conn;
}
catch(SqlException ex)
{
System.Web.HttpContext.Current.Session["messageerror"] = ex.Message;
throw;
} return null;
}
解决方案 »
- asp.net WEB应用程序发布
- System.Data.SqlClient.SqlException: 插入错误: 列名或所提供值的数目与表定义不匹配
- 关于传统HTML的转换的问题
- ReportViewer+rdlc打印,自定义纸型宽24 高10 预览横向打印却是纵向,为什么呀?
- ~~~我碰到一个看似乎简单,但是却很头痛的问题,请大家帮我
- asp.net 2.0 的模板控制问题
- 三级级联菜单绑定
- 怎么样aspx.cs的一个值,调用到javascript的函数里面?
- 怎样获取Treeview的节点的值?
- 网站能获取访问者哪些信息
- 用javascript怎样更改/操作 session 的值?
- 客户端控件是怎么运行的?
{
string Constr = @"server = (local);"+
"user id = sa;"+
"password = 9933;"+
"database = b2c;";
SqlConnection Conn = new SqlConnection(Constr);
return Conn;
}
catch(SqlException ex)
{
System.Web.HttpContext.Current.Session["messageerror"] = ex.Message;
throw;
}
还是不行,我运行了。他并没有catch(SqlException ex)
{
System.Web.HttpContext.Current.Session["messageerror"] = ex.Message;
throw;
}
做到这一步以后打开MessageError.aspx(我做的显示错误)页面。而是一直往下运行。由于后面的代码中得到的conn是返回为null,所以,错误总是出现在下面的代码。。
try
{
...
return a;
}
catch
{
...
}
finally
{
return ...
}