返回dataset
sqldata类里
#region 返回DataSet类型数据
/// <summary>
/// 此方法返回一个DataSet类型
/// </summary>
/// <param name="SqlCom">要执行的SQL语句</param>
/// <returns></returns>
public DataSet ExceDS(string SqlCom)
{
try
{
sqlcom = new SqlCommand(SqlCom, sqlcon);
sqldata = new SqlDataAdapter();
sqldata.SelectCommand = sqlcom;
DataSet ds = new DataSet();
sqldata.Fill(ds);
return ds;
}
finally
{
sqlcon.Close();
}
}
#endregion
在其他类中调用
public static DataTable getPicNewsList()
{
//return DBQuery.OpenQuery("select * from PicNews order by ID asc");
SqlData sd = new SqlData();
return sd.ExceDS("Select * from PicNews order by ID asc").Tables[0];
}