Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in ...
这个问题如何解决,是链接未关闭么?我把能加conn.close()的地方都加了,还是报错啊,反而还多了个错误“Input string was not in a correct format”超时连接池

解决方案 »

  1.   


    Data Source=localhost;Initial Catalog=CRM;User ID=SA;Connect Timeout=1
      

  2.   

    参照下面。Connect Timeout=1去掉。
     <connectionStrings>
      <add name="ConnString" connectionString="Data Source=localhost;Initial Catalog=CRM;User ID=sa;pwd=sa;" providerName="System.Data.SqlClient"/>
     </connectionStrings>参考 http://www.edetime.com/post/144.html
      

  3.   

    下面是连接字符串生成函数,你可以参考个下/// <summary>
            /// 获取Ms Sql数据库联接字符串(使用用户名和密码)
            /// </summary>
            /// <param name="Par_MsSqlSrv">Ms Sql服务器名称或IP地址</param>
            /// <param name="Par_DbName">数据库名称</param>
            /// <param name="Par_UserId">用户名</param>
            /// <param name="Par_UserPwd">密码</param>
            /// <param name="Par_MsSqlTimeOut">超时时间timeout</param>
            /// <param name="Par_Pooling">是否启用连接池</param>
            /// <param name="Par_MinPoolSize">连接池充许的最小连接数</param>
            /// <param name="Par_ApplicationName">应用程序的名称</param>
            /// <returns>联接字符串</returns>
            public static string onGetMsSqlConnStr(string Par_MsSqlSrv, string Par_DbName, string Par_UserId, string Par_UserPwd, int Par_MsSqlTimeOut, bool Par_Pooling, int Par_MinPoolSize, string Par_ApplicationName)
            {
                SqlConnectionStringBuilder xx = new SqlConnectionStringBuilder();
                xx.DataSource = Par_MsSqlSrv;
                xx.InitialCatalog = Par_DbName;
                xx.UserID = Par_UserId;
                xx.Password = Par_UserPwd;
                if (Par_ApplicationName.Length > 0) xx.ApplicationName = Par_ApplicationName;
                if (Par_MsSqlTimeOut > 0) xx.ConnectTimeout = Par_MsSqlTimeOut;
                if (Par_Pooling) xx.Pooling = true;
                if (Par_Pooling && Par_MinPoolSize > 0) xx.MinPoolSize = Par_MinPoolSize;
                return xx.ConnectionString;
            }