finally { closeConnection(); } } /// <summary> /// 返回指定Sql语句的DataTable /// </summary> /// <param name="sqlstr">传入的Sql语句</param> /// <returns>DataTable</returns> public static DataTable dataTable(string sqlstr) { SqlDataAdapter da=new SqlDataAdapter(); DataTable datatable=new DataTable(); try { openConnection(); comm.CommandType =CommandType.Text ; comm.CommandText =sqlstr; da.SelectCommand =comm; da.Fill(datatable); } catch(Exception e) { throw new Exception(e.Message); } finally { closeConnection(); } return datatable; } /// <summary> /// 执行指定Sql语句,同时给传入DataTable进行赋值 /// </summary> /// <param name="sqlstr">传入的Sql语句</param> /// <param name="dt">ref DataTable dt </param> public static void dataTable(string sqlstr,ref DataTable dt) { SqlDataAdapter da=new SqlDataAdapter(); try { openConnection(); comm.CommandType =CommandType.Text ; comm.CommandText =sqlstr; da.SelectCommand =comm; da.Fill(dt); } catch(Exception e) { throw new Exception(e.Message); } finally { closeConnection(); } } /// <summary> |