关于SqlDataReader 的关闭问题
我在过程中是用了CommandBehavior.CloseConnection,具体代码如下
public SqlDataReader GetUserplace(string Value)
{
string conn, sql;
conn = "server=MSSQL;uid=caexpo;pwd=caexpo;database=Question";
sql = Value;
SqlConnection connection = new SqlConnection(conn);
connection.Open();
SqlCommand objCommand = new SqlCommand(sql,connection);
SqlDataReader objReader ;
objReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection);
return objReader;
}
在页面上,我用SqlDataReader objReader = GetUserplace("xxx")进行调用,在调用完成后,我及时的关闭了在页面上创建的objReader ,关闭方法如下:objReader.close();
但是我发现在访问量大的时候,我的数据库连接还是满了,请问应该怎么做?