超时问题,而一次又一次登录 [英] timeout problem while again and again login

查看:85
本文介绍了超时问题,而一次又一次登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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.


这篇关于超时问题,而一次又一次登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆