개발人

ASP 에서 트랜젝션 처리 본문

Classic ASP

ASP 에서 트랜젝션 처리

NJHouse 2014. 8. 3. 17:20
반응형

방법 1

set dbCon = Server.CreateObject("Adodb.Connection")

on Error resume next
dbCon.BeginTrans
strSql = " Insert Into [테이블1명] values("입력값")
dbCon.Execute(strSql)

errNum = errNum + dbCon.errors.Count

strSql = " Insert into [테이블2명] values("입력값1")
dbCon.Execute(strSql)

errNum = errNum + dbCon.errors.Count

strSql = " Insert into [테이블2명] values("입력값2")
dbCon.Execute(strSql)

errNum = errNum + dbCon.errors.Count

If errNum = 0 Then
  dbCon.CommitTrans
  response.write "트랜젝션 성공"
Else
  dbCon.RollbackTrans
  response.write "트랜젝션 실패"
End if

방법 2

set dbCon = Server.CreateObject("Adodb.Connection")

on Error resume next
dbCon.BeginTrans
strSql = " Insert Into [테이블1명] values("입력값")
dbCon.Execute(strSql)

strSql = " Insert into [테이블2명] values("입력값1")
dbCon.Execute(strSql)

strSql = " Insert into [테이블2명] values("입력값2")
dbCon.Execute(strSql)

If dbCon.errors.Count <> 0 Then
  dbCon.errors.Clear
  dbCon.RollbackTrans
  response.write "트랜젝션 실패"
Else
  dbCon.errors.Clear
  dbCon.CommitTrans
  response.write "트랜젝션 성공"
End if


주의 : "관리도구" - "서비스" 에 보면 Distributed Transaction Coordinator 항목이 동작하고 있어야함.


반응형

'Classic ASP' 카테고리의 다른 글

쿠키공유  (0) 2014.08.07
쌍따옴표 & 홑따옴표 치환  (0) 2014.08.07
폴더 생성 및 이름 변경  (0) 2014.08.06
엑셀파일 변환  (0) 2014.08.05
캐시 처리  (0) 2014.08.04
Comments