home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / Code / ch39 / AddCourse.asp next >
Encoding:
Text File  |  1997-07-14  |  1.4 KB  |  60 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <html>
  3. <head>
  4. <title>Save Registration Form</title>
  5. </head>
  6. <body bgcolor="#FFFFFF">
  7. <%
  8. Error = False
  9. If Not IsNumeric(Request.Form("Number")) Then
  10.     Response.Write "<h2>Course Number has to be a Number</h2>"
  11.     Error = True
  12. End If
  13.  
  14. If Not IsNumeric(Request.Form("Cost")) Then
  15.     Response.Write "<h2>Cost has to be a Number</h2>"
  16.     Error = True
  17. End If
  18.  
  19. If Not IsNumeric(Request.Form("Duration")) Then
  20.     Response.Write "<h2>Duration has to be a Number</h2>"
  21.     Error = True
  22. End If
  23.  
  24. If Not Error Then
  25.  
  26.  
  27.     Set Conn = Server.CreateObject("ADODB.Connection")
  28.  
  29.     Set Cmd = Server.CreateObject("ADODB.Command")
  30.  
  31.     Set RSCourse = Server.CreateObject("ADODB.Recordset")
  32.  
  33.     SQL = "Select * From Course"
  34.  
  35.     Cmd.CommandText = SQL
  36.     Cmd.CommandType = 1
  37.  
  38.     Set Cmd.ActiveConnection = Conn
  39.  
  40.     RSCourse.Open Cmd, , 1, 3    
  41.  
  42.     RSCourse.AddNew
  43.     
  44.     RSCourse("Category") = Request.Form("Category")
  45.     RSCourse("Title") = Request.Form("Title")
  46.     RSCourse("Number") = Request.Form("Title")
  47.     RSCourse("Description") = Request.Form("Description")
  48.     RSCourse("Audience") = Request.Form("Audience")
  49.     RSCourse("Prerequisites") = Request.Form("Prerequisites")
  50.     RSCourse("Cost") = Request.Form("Cost")
  51.     RSCourse("Duration") = Request.Form("Duration")
  52.     RSCourse.Update
  53.     
  54.     RSCourse.Close
  55.  
  56.     Response.Write "<h1>Record Added</h1>"
  57.  
  58. End If
  59. %>
  60. </body>
  61. </html>