Conn.begintrans ' Open things function
... The middle is some add modify delete operation
Cancel if there is an error
Conn.rollbacktrans ' Cancel things change and end things
If there's no problem, save it.
Conn.committrans ' Save things and end things
Copy Code code as follows:
<%if not session ("type") = "3" Then
Response. Redirect ". /login.asp "
Else
%>
<!--#include file= ". /conn.asp "-->
<link href= ". /css/home1.css "Type=text/css rel=stylesheet>
<%
Set Rs=server. CreateObject ("Adodb.recordset")
sql = "SELECT * from [Sushe] where m_su= '" & Request. Form ("su") & "'"
Rs.Open sql,conn,1,1
If Rs.recordcount>0 Then
Response.Write ("<p align= ' center ' >" &request.) QueryString ("Name") & ":" & Request. Form ("su") & "is already in storage, please add another" &request. QueryString ("Name") & "! ")
Response. Write "<a href= ' xitong_set.asp ' target= ' mainFrame ' > continue to add </a></p>"
Rs.close
Set rs=nothing
Conn.close
Set conn=nothing
Else
Rs.close
Conn.begintrans ' Open things function
Rs.Open "Sushe", conn,1,3
Rs.addnew ' Insert data to the Users table
RS ("M_su") =request. Form ("su")
Rs.update
Rs.close
If Err.number<>0 Then
Conn.begintrans ' Open things function
... The middle is some add modify delete operation
Cancel if there is an error
Conn.rollbacktrans ' Cancel things change and end things
If there's no problem, save it.
Conn.committrans ' Save things and end things
Response. Write ("<p align= ' center ' > add failed, please add" & "" & ")
Response.Write "<a href= ' xitong_set.asp ' target= ' MainFrame ' > re-add </a></p>"
Else
Conn.committrans ' Save things and end things
Response.Write "<script Language=javascript>alert (' Add success! ');"
Response.Write "settimeout (parent.mainframe.document.location= ' xitong_set.asp ', 0)"
Response.Write "</SCRIPT>"
End If
End If
%>
<%end if%>
<%response. End ()%>