首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

public DataTable数据表如何才能 公用

2013-09-07 
public DataTable数据表怎么才能 公用在类中public DataTable newtable new DataTable()//这里把newtab

public DataTable数据表怎么才能 公用
在类中    public DataTable newtable = new DataTable();  //这里把newtable给public了公用
    public DataTable getlistfalse(out int rowcount)
    {
        newtable.Columns.Add("month", Type.GetType("System.DateTime"));
        DataRow row = newtable.NewRow();
        row["month"] = “2013-9-1”;
        newtable.Rows.Add(row);  这里建了列和行,加进了数据
        }
        rowcount = newtable.Rows.Count;
        return newtable;
    }
然后在这里想访问这个公用的表里面的数据
    public int fengzhang(DateTime month)
    {
        DataRow[] dr = DataRow[] dr = newtable.Select("month='" + month + "'"); //这里报错,未找到列 [month],为什么访问不到表的数据啊,上面不是已经在表里添加过数据了吗?
        ...............
    }

getlistfalse已经在page_load里加载过数据了,怎么样才能把数据读到内存里后在别的地方也能访问,不用再重复去读取数据库
[解决办法]
public static DataTable newtable = new DataTable(); 
试试看

热点排行