// 페이지와 개수에 따라 데이터 가져오는 함수 public SqlDataReader selectAll(int pageNum, int numberPage) { db = new CDatabase(); string sql = "SELECT * FROM Board Order BY board_date DESC" + " OFFSET " + ((pageNum - 1) * numberPage).ToString() + " ROWS;"; SqlDataReader reader = db.GetQueryResult(sql); return(reader); }
// 작성자 검색해주는 쿼리문 public DataTable SelectWriter(String writer) { db = new CDatabase(); DataTable table = new DataTable(); string sql = "SELECT * FROM Board WHERE board_writer LIKE '%" + writer + "%';"; SqlDataReader reader = db.GetQueryResult(sql); table.Load(reader); db.Dispose(); return(table); }
// 내용 검색해주는 쿼리문 public DataTable SelectContent(String content) { db = new CDatabase(); DataTable table = new DataTable(); string sql = "SELECT * FROM Board WHERE board_content LIKE '%" + content + "%';"; SqlDataReader reader = db.GetQueryResult(sql); table.Load(reader); db.Dispose(); return(table); }
// order에 따라 정렬한 데이터 가져오는 함수 public DataTable selectAll(String order) { db = new CDatabase(); DataTable table = new DataTable(); string sql = "SELECT * FROM Board Order BY " + order + ";"; SqlDataReader reader = db.GetQueryResult(sql); table.Load(reader); db.Dispose(); return(table); }
// 전체 board 데이터 가져오는 함수 public DataTable selectAll() { db = new CDatabase(); DataTable table = new DataTable(); string sql = "SELECT * FROM Board Order BY board_date DESC, board_id DESC"; SqlDataReader reader = db.GetQueryResult(sql); table.Load(reader); db.Dispose(); return(table); }
// 전체 검색해주는 쿼리문 public DataTable SelectSum(String all) { db = new CDatabase(); DataTable table = new DataTable(); string sql = "SELECT * FROM Board WHERE board_title LIKE '%" + all + "%'" + "UNION SELECT * FROM Board WHERE board_content LIKE '%" + all + "%'" + "UNION SELECT * FROM Board WHERE board_writer LIKE '%" + all + "%';"; SqlDataReader reader = db.GetQueryResult(sql); table.Load(reader); db.Dispose(); return(table); }
// boardId에 따라 데이터 가져오는 함수 public Boards Select(String boardId) { db = new CDatabase(); Boards board = new Boards(); string sql = "SELECT * FROM Board WHERE board_id =" + boardId + ";"; SqlDataReader reader = db.GetQueryResult(sql); while (reader.Read()) { board.setBoardId(reader.GetInt32(0)); board.setBoardTitle(reader.GetString(1)); board.setBoardWriter(reader.GetString(2)); board.setBoardDate(reader.GetDateTime(3)); board.setBoardContent(reader.GetString(4)); board.setBoardPw(reader.GetString(5)); } db.Dispose(); return(board); }