ExecuteReader 要求已打开且可用的连接。
hsqtl 2011-08-09 09:22:09 f5刷新出现
抛出错误:******************2011-8-9 9:16:3*******************
ExecuteReader 要求已打开且可用的连接。连接的当前状态为正在连接。####select top 8 * from jingq where ntype=1 order by nid desc
*******************2011-8-9 9:16:3*******************
*******************2011-8-9 9:16:4*******************
内部连接致命错误。####select top 10 * from jingq where ntype=2 and jqlx=2 order by nid desc
调用:
this.mjxs.DataSource = SqlDAL.jingq.getNews(8, "jingq", "where ntype=1 ", "nId");
this.mjxs.DataBind();
相关函数
public static DataTable getNews(int top, string table, string where, string id)
{
return DbExec.GetDataTable("select top " + top + " * from " + table + " " + where + " order by " + id + " desc");
}
调用datatable
public static DataTable GetDataTable(string str)
{
DataTable dt = new DataTable();
try
{
Connection();
using ( sqlAda = new SqlDataAdapter(str, sqlCon))
//sqlAda.SelectCommand.CommandTimeout = 60;
{
DataSet ds = new DataSet();
sqlAda.Fill(ds);
ds.CaseSensitive = false;
//dt = ds.Tables[0];
if (ds != null && ds.Tables.Count > 0)
{
dt = ds.Tables[0];
}
}
}
catch (Exception ex)
{
Log.log(ex.Message + "####" + str);
sqlCon.Close();
sqlCon.Dispose();
}
finally
{
sqlCon.Close();
sqlCon.Dispose();
}
return dt;
}
链接
public static void Connection()
{
try
{
sqlCon = new SqlConnection(connectionString);
if (sqlCon.State == System.Data.ConnectionState.Closed)
{
sqlCon.Open();
}
else
{
sqlCon.Close();
sqlCon.Dispose();
}
}
catch (Exception ex)
{
Log.log(ex.Message );
sqlCon.Close();
sqlCon.Dispose();
}
}
请高手给看看什么问题?