first commit
This commit is contained in:
230
Lib/RSExec.asp
Normal file
230
Lib/RSExec.asp
Normal file
@@ -0,0 +1,230 @@
|
||||
<%
|
||||
'=======================================================================
|
||||
'업 무 명 : KRI-common
|
||||
'모듈기능 : 서버 디비 연결자 설정
|
||||
'파 일 명 : Create RecordSet object
|
||||
' 사용할 페이지 에서 call
|
||||
' 사용이 끝나면 객체 반환 call RSClose(RecordSet이름)
|
||||
'작성일자 : 2004/10/09
|
||||
'작 성 자 : 김홍완
|
||||
'-----------------------------------------------------------------------
|
||||
'변경일자 변경자 변동내역
|
||||
'=======================================================================
|
||||
'
|
||||
'=======================================================================
|
||||
'Response.Expires = -1
|
||||
%>
|
||||
<!-- #include file="DBSrv.asp" -->
|
||||
<%
|
||||
'===========================================================================
|
||||
'함수명 : DBexec
|
||||
'INPUT : sSQL(실행할 Query 문장), DBTarget(각 데이타베이스 디바이스 접근 설정)
|
||||
'기능설명 : 단일 데이터 베이스 연결 객체 생성/실행
|
||||
'===========================================================================
|
||||
Function DBexec(sSQL,DBTarget)
|
||||
Dim DBCon, DBTgt
|
||||
On Error Resume Next
|
||||
|
||||
If LEN(sSQL) = 0 Then
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
Response.Write "<br><font size=2>에러스텝 1 : 실행할 SQL문을 입력하세요.</font><br>"
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp?"
|
||||
end if
|
||||
response.end
|
||||
|
||||
Exit function
|
||||
End If
|
||||
|
||||
|
||||
Select Case DBTarget
|
||||
Case "kon" : DBTgt = DBConKon '메인 DB
|
||||
'Case "kon" : DBTgt = DBConKon '메인 DB Dev
|
||||
Case "capi" : DBTgt = DBConCapi 'CAPI
|
||||
Case "krc_urvey": DBTgt = DBConKrcSurvey 'KRC_Survey
|
||||
Case "hmcgmc" : DBTgt = DBConHmcGmc 'DBConHmcGmc
|
||||
Case Else
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
Response.Write "<br><font size=2>에러스텝 2 : 연결할 데이타베이스의 정확한 문자열을 입력하시오!</font><br>"
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
Response.End
|
||||
End Select
|
||||
|
||||
|
||||
'''response.write "<br>----------------"& DBTgt
|
||||
|
||||
|
||||
Set DBCon=Server.CreateObject("ADODB.Connection") 'DB에 연결
|
||||
DBCon.CursorLocation = 3 'client cursor
|
||||
'DBCon.CursorLocation = adUseClient
|
||||
DBCon.CommandTimeout = 0 ' select 쿼리 시간 무제한
|
||||
DBCon.Open DBTgt
|
||||
|
||||
if Err.number <> 0 Then
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
response.write "<br><font size=2>에러스텝 3 : DB Open Error!! 데이터베이스를 정상적으로 연결하지 못하였습니다.</font><br>"
|
||||
Response.Write "<br>" & sSql
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
Response.End
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
Set DBexec = DBCon.Execute(sSQL)
|
||||
|
||||
dim sErr
|
||||
If Err.number <> 0 Then
|
||||
err_source = replace(Err.Source,"'","''")
|
||||
err_description = replace(Err.description,"'","''")
|
||||
err_number = replace(Err.Number,"'","''")
|
||||
err_page = replace(fncRequestVariables("URL"),"'","''")
|
||||
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
sErr = "<TABLE cellSpacing=1 cellPadding=1 width='80%' border=1 align=center>"
|
||||
sErr = sErr & "<TR><TD width='12%' title='"&Err.description&"'><FONT SIZE=2>에러스텝 4</FONT></TD><TD><FONT SIZE=2>개체명이나 컬럼 혹은 인수값이 잘못되었습니다.</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD ><FONT SIZE=2>오류객체명</FONT></TD><TD><FONT SIZE=2>"&Err.Source&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>오류설명</FONT></TD><TD><FONT SIZE=2>"&Err.description&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>오류번호</FONT></TD><TD><FONT SIZE=2>"&Err.Number&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>QUERY</FONT></TD><TD><FONT SIZE=2>"&sSQL&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>에러페이지</FONT></TD><TD><FONT SIZE=2>"&err_page&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>DB Target</FONT></TD><TD><FONT SIZE=2>"&DBTarget&"</FONT></TD></TR>"
|
||||
sErr = sErr & "</TABLE>"
|
||||
Response.Write sErr
|
||||
call DBExecClose(DBcon)
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
Response.End
|
||||
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
End function
|
||||
|
||||
'===========================================================================
|
||||
'함수명 : DBExecClose
|
||||
'INPUT : DBCon
|
||||
'기능설명 : 단일 데이터 베이스 연결 객체 소멸
|
||||
'===========================================================================
|
||||
Function DBExecClose(DBCon)
|
||||
If IsObject(DBCon) = True Then
|
||||
DBCon.Close
|
||||
Set DBCon = Nothing
|
||||
end if
|
||||
End Function
|
||||
|
||||
'===========================================================================
|
||||
'함수명 : RSexec
|
||||
'INPUT : rsName(RecordSet객체를위한Instance 이름),pSize(PageSize 선택)
|
||||
' cType : CursorType 설정
|
||||
' 0 : AdOpenForwardOnly(MoveNext만 지원)
|
||||
' 1 : AdOpenKeyset(변경 데이타는 볼 수 없음)
|
||||
' 2 : AdOpenDynamic(모든 방식의 커서지원)
|
||||
' 3 : AdOpenStatic(데이타 검색이나 레포트 생성시에 사용)
|
||||
' sSQL(실행할 Query 문장),DBTarget(각 데이타베이스 디바이스 접근 설정)
|
||||
'기능설명 : 레코드셋 객체 생성/실행
|
||||
'===========================================================================
|
||||
Function RSexec(rsName,pSize,cType,sSQL,DBTarget)
|
||||
|
||||
Dim globalDBCon, DBTgt
|
||||
On Error Resume Next
|
||||
|
||||
If LEN(sSQL) = 0 Then
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
Response.Write "<br><font size=2>에러스텝 1 : 실행할 SQL문을 입력하세요.</font><br>"
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
response.end
|
||||
Exit function
|
||||
End If
|
||||
|
||||
Select Case DBTarget
|
||||
Case "kon" : DBTgt = DBConKon '메인 DB
|
||||
'Case "kon" : DBTgt = DBConKon '메인 DB Dev
|
||||
Case "capi" : DBTgt = DBConCapi 'CAPI
|
||||
Case "krc_urvey": DBTgt = DBConKrcSurvey 'KRC_Survey
|
||||
'------------------------------------------------------------------------------------------------------
|
||||
Case Else
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
Response.Write "<br><font size=2>에러스텝 2B : 연결할 데이타베이스의 정확한 문자열을 입력하시오!</font><br>"
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
Response.End
|
||||
|
||||
End Select
|
||||
|
||||
If IsObject(globalDBCon) = False Then
|
||||
Set globalDBCon = Server.CreateObject("ADODB.Connection")
|
||||
globalDBCon.CursorLocation = 3 'client cursor
|
||||
'globalDBCon.CursorLocation = adUseClient
|
||||
globalDBCon.CommandTimeout = 0 ' select 쿼리 시간 무제한
|
||||
globalDBCon.Open DBTgt
|
||||
|
||||
if Err.number <> 0 Then
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
response.write "<br><font size=2>에러스텝 3 : DB Open Error!! 데이터베이스를 정상적으로 연결하지 못하였습니다.</font><br>"
|
||||
Response.Write "<br>" & sSql
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
Response.End
|
||||
Exit Function
|
||||
End If
|
||||
End If
|
||||
|
||||
Set rsName = Server.CreateObject("ADODB.RecordSet")
|
||||
|
||||
globalDBCon.CursorLocation = 3
|
||||
RSName.Open sSQL, globalDBCon, Ctype
|
||||
|
||||
If Err.number <> 0 Then
|
||||
err_source = replace(Err.Source,"'","''")
|
||||
err_description = replace(Err.description,"'","''")
|
||||
err_number = replace(Err.Number,"'","''")
|
||||
err_page = replace(fncRequestVariables("URL"),"'","''")
|
||||
|
||||
if fncRequestVariables("LOCAL_ADDR")="10.10.13.82" then
|
||||
sErr = "<TABLE cellSpacing=1 cellPadding=1 width='80%' border=1 align=center>"
|
||||
sErr = sErr & "<TR><TD width='12%' title='"&Err.description&"'><FONT SIZE=2>에러스텝 4B</FONT></TD><TD><FONT SIZE=2>개체명이나 컬럼 혹은 인수값이 잘못되었습니다.</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD ><FONT SIZE=2>오류객체명</FONT></TD><TD><FONT SIZE=2>"&Err.Source&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>오류설명</FONT></TD><TD><FONT SIZE=2>"&Err.description&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>오류번호</FONT></TD><TD><FONT SIZE=2>"&Err.Number&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>QUERY</FONT></TD><TD><FONT SIZE=2>"&sSQL&"</FONT></TD></TR>"
|
||||
sErr = sErr & "<TR><TD><FONT SIZE=2>에러페이지</FONT></TD><TD><FONT SIZE=2>"&err_page&"</FONT></TD></TR>"
|
||||
sErr = sErr & "</TABLE>"
|
||||
Response.Write sErr
|
||||
call RSclose(rsName)
|
||||
else
|
||||
response.Redirect "/etc/error/error.asp"
|
||||
end if
|
||||
|
||||
Response.End
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
'===========================================================================
|
||||
'함수명 : RSClose
|
||||
'INPUT : rsName
|
||||
'기능설명 : 레코드셋 객체 소멸
|
||||
'===========================================================================
|
||||
Function RSClose(rsName)
|
||||
Dim globalDBCon
|
||||
|
||||
if IsObject(rsName) = True Then
|
||||
rsName.Close
|
||||
Set rsName = Nothing
|
||||
end if
|
||||
If IsObject(globalDBCon) = True Then
|
||||
globalDBCon.Close
|
||||
Set globalDBCon = Nothing
|
||||
End If
|
||||
End Function
|
||||
|
||||
%>
|
||||
Reference in New Issue
Block a user