dr.Close(); } catch { } finally { closeConnection(); } } } /// <summary> /// 返回指定Sql语句的DataSet /// </summary> /// <param name="sqlstr">传入的Sql语句</param> /// <returns>DataSet</returns> public static DataSet dataSet(string sqlstr) { DataSet ds= new DataSet(); SqlDataAdapter da=new SqlDataAdapter(); try { openConnection(); comm.CommandType =CommandType.Text ; comm.CommandText =sqlstr; da.SelectCommand =comm; da.Fill(ds); } catch(Exception e) { throw new Exception(e.Message); } finally { closeConnection(); } return ds; } /// <summary> /// 返回指定Sql语句的DataSet /// </summary> /// <param name="sqlstr">传入的Sql语句</param> /// <param name="ds">传入的引用DataSet对象</param> public static void dataSet(string sqlstr,ref DataSet ds) { SqlDataAdapter da=new SqlDataAdapter(); try { openConnection(); comm.CommandType =CommandType.Text ; comm.CommandText =sqlstr; da.SelectCommand =comm; da.Fill(ds); } catch(Exception e) { throw new Exception(e.Message); } |