大家看看我的代码有没有错,是数据库连接

llwlz 2009-12-09 10:17:59
namespace Utility
{
public static class ORAConntion
{
private static string constr = ConfigurationManager.AppSettings["ConnectionString"];
private static OracleConnection ORAConn;

public static OracleConnection GetOracleGetConnection()
{
try
{
if (ORAConn == null)
{
ORAConn = new OracleConnection(constr);
ORAConn.Open();
}
else if (ORAConn.State == ConnectionState.Closed)
{
ORAConn.Open();
}

return ORAConn;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
...全文
173 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
msy_84 2009-12-14
  • 打赏
  • 举报
回复
catch (Exception ex)
{
throw ex;
}
好奇怪的代码...(*^__^*) 嘻嘻……

还有,catch 中也要有返回语句的,return null
lsj47987850 2009-12-14
  • 打赏
  • 举报
回复
顶起。。。
llwlz 2009-12-14
  • 打赏
  • 举报
回复
有没有人看看
Return门徒 2009-12-09
  • 打赏
  • 举报
回复
没错吧,这东西我都是一次编写,终身使用
c_l2009 2009-12-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 erydemimi 的回复:]
引用 3 楼 caotoulei 的回复:
你干吗catch 了有throw? 别忘了close()

我也觉得奇怪
[/Quote]
en
erydemimi 2009-12-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 caotoulei 的回复:]
你干吗catch 了有throw? 别忘了close()
[/Quote]
我也觉得奇怪
caotoulei 2009-12-09
  • 打赏
  • 举报
回复
你干吗catch 了有throw? 别忘了close()
gablfq 2009-12-09
  • 打赏
  • 举报
回复
namespace Utility
{
public static class ORAConntion
{
private static string constr = ConfigurationManager.AppSettings["ConnectionString"];
private static OracleConnection ORAConn;

public static OracleConnection GetOracleGetConnection()
{
try
{
if (ORAConn == null)
{
ORAConn = new OracleConnection(constr);
ORAConn.Open();
}
else if (ORAConn.State == ConnectionState.Closed)
{
ORAConn.ConnectionString = constr;
ORAConn.Open();
}

return ORAConn;
}
catch (Exception ex)
{
throw ex;
}
}
}
}

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧