티스토리 뷰
728x90
반응형
시나리오
정보
internal DataSet getBoardList(ref BoardVariable.BoardList variable)
{
int startRecode = (variable.currentPage - 1) * variable.pageSize;
int topCount = variable.currentPage * variable.pageSize;
SqlConnection conn = new SqlConnection(DBconnectionString);
SqlCommand comm = new SqlCommand("getBoardList", conn);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.Add("@BoardID", SqlDbType.VarChar, 12).Value = variable.boardID;
comm.Parameters.Add("@SearchOption", SqlDbType.VarChar, 10).Value = variable.searchOption;
comm.Parameters.Add("@SearchKey", SqlDbType.VarChar, 30).Value = variable.searchKey;
comm.Parameters.Add("@TopCount", SqlDbType.VarChar, 12).Value = topCount.ToString();
comm.Parameters.Add("@Query", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output;
SqlDataAdapter adapter = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
try
{
adapter.Fill(ds, startRecode, variable.pageSize, "BoardList");
throw new Exeception(comm.Parameter["@Query"].Value.ToString());
{
int startRecode = (variable.currentPage - 1) * variable.pageSize;
int topCount = variable.currentPage * variable.pageSize;
SqlConnection conn = new SqlConnection(DBconnectionString);
SqlCommand comm = new SqlCommand("getBoardList", conn);
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.Add("@BoardID", SqlDbType.VarChar, 12).Value = variable.boardID;
comm.Parameters.Add("@SearchOption", SqlDbType.VarChar, 10).Value = variable.searchOption;
comm.Parameters.Add("@SearchKey", SqlDbType.VarChar, 30).Value = variable.searchKey;
comm.Parameters.Add("@TopCount", SqlDbType.VarChar, 12).Value = topCount.ToString();
comm.Parameters.Add("@Query", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output;
SqlDataAdapter adapter = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
try
{
adapter.Fill(ds, startRecode, variable.pageSize, "BoardList");
throw new Exeception(comm.Parameter["@Query"].Value.ToString());
return ds;
}
catch (Exception e)
{
throw e;
}
}
}
catch (Exception e)
{
throw e;
}
}
비고
[DBMS]
ALTER PROCEDURE getBoardList
@BoardID varchar(12),
@SearchOption varchar(10),
@SearchKey varchar(30),
@TopCount varchar(12),
@Query varchar(200) output
AS
DECLARE @QuerySentence varchar(512)
-- 검색 정보가 없는 경우
IF(@SearchKey = '검색어')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList'+
' Where BoardID = '+char(39)+@BoardID+char(39)+
' ORDER BY GroupID DESC, GroupStep ASC'
-- '제목'이나 '작성자'로 검색하는 경우
ELSE IF(@SearchOption = 'Subject' OR @SearchOption = 'Writer')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList'+
' Where BoardID = '+char(39)+@BoardID+char(39)+
' AND '+@SearchOption+' LIKE '+char(39)+'%'+@SearchKey+'%'+char(39)+
' ORDER BY GroupID DESC, GroupStep ASC'
-- '본문 내용으로 검색하는 경우'
ELSE IF(@SearchOption = 'Content')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList inner join BoardContent'+
' on BoardContent.BoardID = '+char(39)+@BoardID+char(39)+
' and BoardContent.BoardID = BoardList.BoardID'+
' and BoardContent.GroupID = BoardList.GroupID'+
' and BoardContent.GroupStep = BoardList.GroupStep'+
' where BoardContent.Content LIKE '+char(39)+'%'+@SearchKey+'%'+char(39)+
' ORDER BY BoardContent.GroupID DESC, BoardContent.GroupStep ASC'
EXEC(@QuerySentence)
Set @Query = @QuerySentence
ALTER PROCEDURE getBoardList
@BoardID varchar(12),
@SearchOption varchar(10),
@SearchKey varchar(30),
@TopCount varchar(12),
@Query varchar(200) output
AS
DECLARE @QuerySentence varchar(512)
-- 검색 정보가 없는 경우
IF(@SearchKey = '검색어')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList'+
' Where BoardID = '+char(39)+@BoardID+char(39)+
' ORDER BY GroupID DESC, GroupStep ASC'
-- '제목'이나 '작성자'로 검색하는 경우
ELSE IF(@SearchOption = 'Subject' OR @SearchOption = 'Writer')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList'+
' Where BoardID = '+char(39)+@BoardID+char(39)+
' AND '+@SearchOption+' LIKE '+char(39)+'%'+@SearchKey+'%'+char(39)+
' ORDER BY GroupID DESC, GroupStep ASC'
-- '본문 내용으로 검색하는 경우'
ELSE IF(@SearchOption = 'Content')
SET @QuerySentence = 'Select TOP '+@TopCount+' BoardList.*'+
' From BoardList inner join BoardContent'+
' on BoardContent.BoardID = '+char(39)+@BoardID+char(39)+
' and BoardContent.BoardID = BoardList.BoardID'+
' and BoardContent.GroupID = BoardList.GroupID'+
' and BoardContent.GroupStep = BoardList.GroupStep'+
' where BoardContent.Content LIKE '+char(39)+'%'+@SearchKey+'%'+char(39)+
' ORDER BY BoardContent.GroupID DESC, BoardContent.GroupStep ASC'
EXEC(@QuerySentence)
Set @Query = @QuerySentence
728x90
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- java.sql
- jstl(java standard tag library)
- 진수 변환
- .submit()
- await
- 스프링 프레임워크(spring framewordk)
- 스프링 시큐리티(spring security)-http basic 인증
- React
- 스프링 프레임워크(spring framework)
- 인텔리제이(intellij)
- nl2br
- error-java
- 메이븐(maven)
- System.Diagnostics
- MainActor
- jstl(java standard tag library)-core
- 제품 등록
- In App Purchase
- jsp 오픈 소스
- java 키워드 정리
- 스프링 시큐리티(spring security)
- 상품 등록
- 람다식(lambda expression)
- system.io
- 표현 언어(expression language)
- java web-mvc
- REST API
- 문자 자르기
- java-개발 환경 설정하기
- 특정 문자를 기준으로 자르기
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함