超时问题,而一次又一次登录

编程入门 行业动态 更新时间:2024-10-26 17:29:35
本文介绍了超时问题,而一次又一次登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我登录我的网页并注销时,再次使用另一个密码和用户及密码再次登录和注销......再次显示...它显示以下错误:

When I logged into my webpage and logout,,and again login and logout with another password and user and password..again again... Its shows the following error:

System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at Bal_Login.CheckDummy() in ...

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

推荐答案

按照我之前的评论,这里是你的代码的格式化版本,其中我使用using语句。

Following my earlier comment, here is a formatted version of your code wherein I use the using statement. protected void ImgLogin_Click ( object sender, ImageClickEventArgs e ) { try { string command_string; string connection_string; command_string = "SELECT * " + "FROM tbl_login_user " + "WHERE username=@username AND " + "password=@password"; connection_string = ConfigurationManager. ConnectionStrings [ "constrings" ]. ConnectionString; using ( SqlConnection SQL_connection = new SqlConnection ( connection_string ) ) { SQL_connection.Open ( ); using ( SqlCommand SQL_command = new SqlCommand ( command_string, SQL_connection ) ) { SQL_command.Parameters.AddWithValue ( "@username", txtusername.Text ); SQL_command.Parameters.AddWithValue ( "@password", txtpwduser.Text); using ( SqlDataReader SQL_data_reader = SQL_command. ExecuteReader ( ) ) { SQL_data_reader.Read ( ); if ( SQL_data_reader.HasRows ) { Response.Redirect ( "~/Adminlogin/home.aspx", false); } else { msg.ShowAlertMessage ( "Invalid Login Credentials" ); } } } } } catch ( Exception ex ) { Response.Write ( ex.ToString ( ) ); } }

SQL_connection,SQL_command和SQL_data_reader都将关闭在每个使用语句块的末尾。

SQL_connection, SQL_command, and SQL_data_reader will all be closed at the end of each's using statement block.

代替using语句,你可以使用一个完成块,以确保在try块中打开的所有对象都已关闭。

In place of the using statements, you could use a single finish block to insure that all object opened in the try block are closed.

更多推荐

超时问题,而一次又一次登录

本文发布于:2023-11-27 23:52:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!