%
'=======================================================================
'업 무 명 : KRI-common
'모듈기능 : 서버 디비 연결자 설정
'파 일 명 : Create RecordSet object
' 사용할 페이지 에서 call
' 사용이 끝나면 객체 반환 call RSClose(RecordSet이름)
'작성일자 : 2004/10/09
'작 성 자 : 김홍완
'-----------------------------------------------------------------------
'변경일자 변경자 변동내역
'=======================================================================
'
'=======================================================================
'Response.Expires = -1
%>
<%
'===========================================================================
'함수명 : 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 "
에러스텝 1 : 실행할 SQL문을 입력하세요.
"
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 "
에러스텝 2 : 연결할 데이타베이스의 정확한 문자열을 입력하시오!
"
else
response.Redirect "/etc/error/error.asp"
end if
Response.End
End Select
'''response.write "
----------------"& 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 "
에러스텝 3 : DB Open Error!! 데이터베이스를 정상적으로 연결하지 못하였습니다.
"
Response.Write "
" & 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 = "
"
sErr = sErr & "| 에러스텝 4 | 개체명이나 컬럼 혹은 인수값이 잘못되었습니다. |
"
sErr = sErr & "| 오류객체명 | "&Err.Source&" |
"
sErr = sErr & "| 오류설명 | "&Err.description&" |
"
sErr = sErr & "| 오류번호 | "&Err.Number&" |
"
sErr = sErr & "| QUERY | "&sSQL&" |
"
sErr = sErr & "| 에러페이지 | "&err_page&" |
"
sErr = sErr & "| DB Target | "&DBTarget&" |
"
sErr = sErr & "
"
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 "
에러스텝 1 : 실행할 SQL문을 입력하세요.
"
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 "
에러스텝 2B : 연결할 데이타베이스의 정확한 문자열을 입력하시오!
"
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 "
에러스텝 3 : DB Open Error!! 데이터베이스를 정상적으로 연결하지 못하였습니다.
"
Response.Write "
" & 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 = ""
sErr = sErr & "| 에러스텝 4B | 개체명이나 컬럼 혹은 인수값이 잘못되었습니다. |
"
sErr = sErr & "| 오류객체명 | "&Err.Source&" |
"
sErr = sErr & "| 오류설명 | "&Err.description&" |
"
sErr = sErr & "| 오류번호 | "&Err.Number&" |
"
sErr = sErr & "| QUERY | "&sSQL&" |
"
sErr = sErr & "| 에러페이지 | "&err_page&" |
"
sErr = sErr & "
"
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
%>