发布网站遇到的问题~~~~

蕾丝凶兆 2010-10-18 01:20:26
我用asp.net完成了个网站~~~~我发布到我的iis上~~~通过浏览器访问,登录时,提示连接池满了 ~~~~~~
这种情况大都出现在登录(一打开网站)或者登陆进去后,读取一个数据量较大的数据库时,出现这样的错误???
为什么 我用本机的vs2008直接运行,没有这样的错误~~~
是我的iis问题 还是我要优化一下我的代码(数据库查询字符串 没有多少存储过程和视图)
我的开发版本是 vs2008 sql2005 xp的系统 iis5.1
求解决方案~·~~~~~~
thank you~~~~~
...全文
122 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhulong1111 2010-10-18
  • 打赏
  • 举报
回复
应该是写的通用类问题 最好去官方下个数据库读写类..
zhulong1111 2010-10-18
  • 打赏
  • 举报
回复
[Quote=引用楼主 xiaomaow 的回复:]
我用asp.net完成了个网站~~~~我发布到我的iis上~~~通过浏览器访问,登录时,提示连接池满了 ~~~~~~
这种情况大都出现在登录(一打开网站)或者登陆进去后,读取一个数据量较大的数据库时,出现这样的错误???
为什么 我用本机的vs2008直接运行,没有这样的错误~~~
是我的iis问题 还是我要优化一下我的代码(数据库查询字符串 没有多少存储过程和视图)
我的开发版本是 vs……
[/Quote]SqlDataReader 虽然读取数度快,可必须连接一直打开?是否这个问题
仙儿 2010-10-18
  • 打赏
  • 举报
回复
去GOOGLE搜吧 我也是搜出来解决的 而且你这个在本地
蕾丝凶兆 2010-10-18
  • 打赏
  • 举报
回复
我的iis 就是装在本机上面~~~
仙儿 2010-10-18
  • 打赏
  • 举报
回复
哈哈 我以前也遇到过这样的情况 链接远程服务器说的是连接满了 你这个找下服务器商 还有就是你的IIS设置有问题的
蕾丝凶兆 2010-10-18
  • 打赏
  • 举报
回复
有关闭啊~~~~~
static string connString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
private static SqlConnection Connection=new SqlConnection(connString);

/// <summary>
/// 执行非查询操作
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static int GetCommand(string sql)
{
try
{
Connection.Open();
SqlCommand command = new SqlCommand(sql, Connection);
int result = command.ExecuteNonQuery();
}
catch (Exception ex)
{

}
finally
{
Connection.Close();
return result;
}
}

/// <summary>
/// 查找第一行第一列的值
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static int GetScalar(string sql)
{
try
{
Connection.Open();
SqlCommand command = new SqlCommand(sql, Connection);
int result = (int)command.ExecuteScalar();
}
catch (Exception ex)
{

}
finally
{
Connection.Close();
return result;
}
}

/// <summary>
/// 执行读取操作
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static SqlDataReader GetRead(string sql)
{
try
{
SqlCommand command = new SqlCommand(sql, Connection);
SqlDataReader reader = command.ExecuteReader();
}
catch (Exception ex)
{

}
finally
{
Connection.Close();
return reader;
}
}

/// <summary>
/// 查询一张表
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static DataTable GetTable(string sql)
{
try
{
Connection.Open();
DataSet ds = new DataSet();
SqlCommand command = new SqlCommand(sql, Connection);
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(ds);
}
catch (Exception ex)
{
}
finally
{
Connection.Close();
return ds.Tables[0];
}

}
这是我数据库操作 都是执行着里面的代码~~~
数据库 打开和关闭 都是这里面的~~~~~~~
annekay 2010-10-18
  • 打赏
  • 举报
回复
1.连接有没有关闭。connectinon.close()
2.释放资源
yangxueke 2010-10-18
  • 打赏
  • 举报
回复
读取数据的后是不是数据库的连接没有关闭?
fancongcong89 2010-10-18
  • 打赏
  • 举报
回复
你没有优化代码和加载一些数据,你可以把数据库换成access数据库因为sql2005的占用空间比较大。
fellowcheng 2010-10-18
  • 打赏
  • 举报
回复
优化数据访问层的代码再试下

62,271

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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