Hello I got this below asp code which creats new record and i need commit and rollback support in case of error while updating.
Server is windows 2000 and IIS and access database 2000 format.
Please some body help me.
Thank you,
Prashanth
<%
On Error Resume Next
'======= Retrieve the data sent with the URL
On Error Resume Next
Dim Problem
Problem = "None"
Dim strLast
strLast = Request.Form("lastname")
if strLast = "" then strLast = "N/A "
Dim strFirst
strFirst = Request.Form("firstname")
if strFirst = "" then strFirst = "N/A "
Dim strGender
strGender = Request.Form("gender")
if strGender = "" then strGender = "N/A "
Dim strAddress
strAddress = Request.Form("address")
if strAddress = "" then strAddress = "N/A "
Dim strCity
strCity = Request.Form("city")
if strCity = "" then strCity = "N/A "
Dim strState
strState = Request.Form("state")
if strState = "" then strState = "N/A "
Dim strZip
strZip = Request.Form("zip")
if strZip = "" then strZip = "N/A "
%>
------------------------
<% '======= Open the database connection
Dim sql
Set cnn1 = Server.CreateObject("ADODB
.Connectio
n")
If Err Then Problem = "True"
openStr = "driver={Microsoft Access Driver (*.mdb)};" &_
"dbq=" & Server.MapPath("database/d
ata.mdb")
If Err Then Problem = "True"
cnn1.Open openStr, "",""
If Err Then Problem = "True"
sql = "SELECT * FROM Contestants;"
Set rs = Server.CreateObject("ADODB
.Recordset
")
rs.Open sql, cnn1, 1, 3
If Err Then Problem = "Can't Open"
'======= Add the New record
rs.AddNew
rs("category") = strCategory
rs("lastname") = strLast
rs("firstname") = strFirst
rs("address") = strAddress
rs("city") = strCity
rs("state") = strState
rs("zip") = strZip
rs("regdate") = Date()
rs("regtime") = Time()
rs.Update
If Err Then Problem = Problem & " Can't Update"
If (Problem <> "None") Then
Response.Write "ERROR!<br>"
Response.Write "An unexpected error has occured (" & Err & " " & Problem & ") while processing your data.<br>"
Response.Write "Please DO NOT SUBMIT AGAIN and CONTACT US by selecting contact from above menu<br>"
Response.Write "Please send us the name, email of the person registering while contacting us<br>"
Else
//Print congratulations screen.
//Print congratulations screen.
//Print congratulations screen.
End If
'======= Close the recordset
rs.Close
set rs = Nothing
'=======Close the database connection
cnn1.Close
Set cnn1 = Nothing
%>