日期:2014-05-16 浏览次数:20423 次
public static DataSet dataSet(string sql)
{
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("Server=(local);UID=**;PWD=**;DATABASE=**");
cn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
da.Fill(ds);
cn.Close();
return ds;
}
public static SqlDataReader dataReader(string sql)
{
SqlConnection cn = new SqlConnection("Server=(local);UID=**;PWD=**;DATABASE=**");
cn.Open();
SqlCommand cm = new SqlCommand(sql, cn);
SqlDataReader dr = cm.ExecuteReader();
cn.Close();
return dr;
}