<% @ Language=VBScript %> <% Response.Buffer = True %> <% If Validated() Then SaveDivision() Set dbNVS = Nothing Response.Clear Response.Redirect "division_add.asp?confirm=yes" Response.End End If %> <% Function Validated()%> <% On Error Resume Next Validated = False 'validate the "NAME" field.... If Trim(Request.Form("txtDivName")) = "" OR IsNull(Trim(Request.Form("txtDivName"))) Then Response.Clear Response.Redirect "error.asp?mess=You must supply a Division Name.
Please click the BACK button." Response.End End If If Len(Trim(Request.Form("txtDivName"))) > 25 Then Response.Clear Response.Redirect "error.asp?mess=The Division Name can only be 25 characters long.
Please click the BACK button." Response.End End If Validated = True End Function %> <% '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function SaveDivision()%> <% On Error Resume Next SaveDivision = False Set cmdDiv = Server.CreateObject("ADODB.Command") Dim strSQL strSQL = "Insert Into [DIVISION] (" strSQL = strSQL + " [DIVISION]" strSQL = strSQL + " ) Values (" strSQL = strSQL + "'" + SQLFixTicks(Trim(Request.Form("txtDivName"))) + "')" dbNVS.Open cmdDiv.ActiveConnection = dbNVS cmdDiv.CommandText = strSQL dbNVS.BeginTrans cmdDiv.Execute 'Error Handling in a small way... If Err.Number <> 0 then 'if something goes wrong, don't update the database... dbNVS.RollBack 'something is wrong... Response.Clear Response.Redirect "error.asp?mess=A system error occured with the function SaveDivision." + _ "
Please click the back button." Response.End SaveDivision = False End if dbNVS.CommitTrans dbNVS.Close Set cmdDiv = Nothing SaveDivision = True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %>