Beispiel #1
0
 /// <summary>
 /// 根据查询语句返回DataTable
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="as_where1">如:@name=sa</param>
 /// <param name="as_where2"></param>
 /// <param name="as_where3"></param>
 /// <param name="as_where4"></param>
 /// <param name="as_where5"></param>
 /// <param name="as_where6"></param>
 /// <returns></returns>
 public static DataTable ExecuteDataTable(string sql, string as_where1 = "", string as_where2 = "", string as_where3 = "", string as_where4 = "", string as_where5 = "", string as_where6 = "")
 {
     sql = of_AllSql(sql, as_where1, as_where2, as_where3, as_where4, as_where5, as_where6);
     DataTable dt = new DataTable();
     AccessDB db = new AccessDB(connStr);
     try
     {
         dt = db.ExecuteQueryDataTable(sql);
         return dt;
     }
     catch (Exception e)
     {
         SqlErr = e.Message;
         return dt;
     }
     finally
     {
         db.CloseSqlConnection();
     }
 }
Beispiel #2
0
 /// <summary>
 /// 分页方法
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="ai_PageSize">每页行数</param>
 /// <param name="ai_PageIndex">当前页数</param>
 /// <param name="ai_totalrow">总行数</param>
 /// <returns></returns>
 public static DataTable ExecuteDataTable(string sql, int ai_PageSize, int ai_PageIndex, ref int ai_totalrow)
 {
     if (ai_PageSize > 20000)
     {
         ai_PageSize = 20000;
     }
     DataTable dt = new DataTable();
     AccessDB db = new AccessDB(connStr);
     if (sql.IndexOf("limit") > 0)
     {
         sql = sql.Substring(0, sql.IndexOf("limit"));
     }
     try
     {
         ai_totalrow = db.ExecuteQueryNum(sql);
         if (ai_PageIndex == 1)
         {
             sql += " limit 0," + ai_PageSize;
         }
         else
         {
             sql += " limit " + (ai_PageIndex * ai_PageSize - 1) + "," + ai_PageSize;
         }
         dt = db.ExecuteQueryDataTable(sql);
         return dt;
     }
     catch (Exception e)
     {
         SqlErr = e.Message;
         return dt;
     }
     finally
     {
         db.CloseSqlConnection();
     }
 }
Beispiel #3
0
 /// <summary>
 /// 根据查询语句返回DataTable
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public static DataTable ExecuteDataTable(string sql)
 {
     DataTable dt = new DataTable();
     AccessDB db = new AccessDB(connStr);
     try
     {
         dt = db.ExecuteQueryDataTable(sql);
         return dt;
     }
     catch (Exception e)
     {
         SqlErr = e.Message;
         return dt;
     }
     finally
     {
         db.CloseSqlConnection();
     }
 }