超时时间已到。在从池中获取连接之前超时时间已过?
超时时间已到。在从池中获取连接之前超时时间已过?
老是连接池超时,是连接池没有关闭!
我是个新手,请问下,各位大哥大姐,在哪里解决他的关闭问题,还不能改变原有的类,谢谢了!由于帖子不能太长,我就分成两段!
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace GdVnet.GdVnetClass
{
public class W_SqlHelper
{
public SqlCommandBuilder updatebuilder;
public W_SqlHelper()
{
}
public static readonly string CONN_STRING1= ConfigurationSettings.AppSettings[ "ConnectionString1 "];
public static readonly string CONN_STRING2= ConfigurationSettings.AppSettings[ "ConnectionString2 "];
private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());
public static DataSet tablesDs=new DataSet();
public static int ExecuteNonQuery(string connString, CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(connString))
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
}
public static int ExecuteNonQuery(SqlConnection conn, CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, cmdParms);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
{
return ExecuteReader(connectionString, commandType, commandText, (SqlParameter[])null);
}
public static SqlDataReader ExecuteReader(string connString, CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connString);
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return rdr;
}
catch
{
conn.Close();
throw;
}
}
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)