发现我做的网页有时不能访问数据库

thordon 2006-03-27 10:54:02
报没有找到数据库,或数据库拒绝访问. 有时有这个问题. 有时没有. 但我用查询分析器 异地访问 都没有问题.
...全文
90 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
thordon 2006-03-29
  • 打赏
  • 举报
回复
public static int ExecuteNonQuery(string cmdText, CommandType cmdtype)
{
int retVal = 0;
using (SqlConnection conn = new SqlConnection(connStr))
{
SqlCommand cmd = new SqlCommand(cmdText, conn);
cmd.CommandType = cmdtype;

try {
conn.Open();
retVal = cmd.ExecuteNonQuery();
}
catch(Exception exp){
//如果发生错误,则转到错误显示页面
HttpContext.Current.Response.Redirect("errMessage.aspx?errMsg=" + HttpContext.Current.Server.UrlEncode(exp.Message));
HttpContext.Current.Response.End();
}
finally {
conn.Close();
}
}
return retVal;
}
Knight94 2006-03-28
  • 打赏
  • 举报
回复
首先,把你的连接字符串贴出来,看看你的连接方式
thordon 2006-03-28
  • 打赏
  • 举报
回复
不懂楼上的意思 是防火墙开的问题?
hywyjw 2006-03-27
  • 打赏
  • 举报
回复
是不是你安装了什么防病D软件, 而它又屏蔽了一些端口,正好是你数据使用的? 建议你先删除它慢慢一步步排查
Lucky527 2006-03-27
  • 打赏
  • 举报
回复
服务器端的防火墙打开
thordon 2006-03-27
  • 打赏
  • 举报
回复
可是 是有时候 不能上 有时候能上啊.

110,538

社区成员

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

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

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