各位大侠求救啊,我是新手,在做网站的时候碰到这个问题“ The IListSource does not contain any data sources”,网站发布后,有时候没有问题可以访问网站,但有的时候就莫名奇妙的出现这个问题。
The IListSource does not contain any data sources. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The IListSource does not contain any data sources.Source Error: 
Line 47:             string strWhere = "select top 10 Title from WS_CompayNews order by Date desc";
Line 48:             RpNews.DataSource = DBUtility.DbHelperSQL.Query(strWhere);
Line 49:             RpNews.DataBind();Line 50:             
Line 51:     
 
数据绑定我调用的三层架构里的代码,webconfig配置我设置的是本机,如果用上用户名和密码,但同样会出现这样的问题。请各位大侠多多指教。

解决方案 »

  1.   

    是不是你的SQL语句查出来的结果集是空的。
      

  2.   

    Line 47: string strWhere = "select top 10 Title from WS_CompayNews order by Date desc";
    先看这个查询语句查出结果吗!
      

  3.   

    查询的结果能够显示,之前我不是用三层写的代码,可以查询出结果。现在用三层写的代码,数据操作代码如下:
    public static DataSet Query(string SQLString)
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    DataSet ds = new DataSet();
                    try
                    {
                        connection.Open();
                        SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
                        command.Fill(ds, "ds");
                        connection.Close();
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    return ds;
                    
                }
            }
    网站一会儿能看到运行效果,一会儿又看不到效果,真的很纠结啊。
    这个问题是不是和数据操作过于频繁有关系呢,我其它页面有些数据绑定没有用到三层,这样会不会写造成数据操作过于频繁?
      

  4.   


    就是有些时候运行能够看到网站的效果和界面,而有的时候就会在网页上提示那个错误(The IListSource does not contain any data sources)。
      

  5.   

    页面没有刷新,出现问题的时候进不去主页,在网页里直接显示The IListSource does not contain any data sources。
      

  6.   

    可以调试,调试的是也是偶尔出现那个问题,有的时候调试没有问题,可以直接看到运行效果。当调试有问题的时候就是显示IListSource does not contain any data sources。