日期:2014-05-17  浏览次数:21444 次

解决Timeout expired. The timeout period elapsed prior to obtaining a connection
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”
超时 连接池

------解决方案--------------------
应该是连接字符串写错了,你把连接字符串贴出来看看
------解决方案--------------------
引用:
引用:应该是连接字符串写错了,你把连接字符串贴出来看看
Data Source=localhost;Initial Catalog=CRM;User ID=SA;Connect Timeout=1

参照下面。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
------解决方案--------------------
下面是连接字符串生成函数,你可以参考个下

/// <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;