Hello everyone. I've got a form I want to use to submit to a simple Access database. Here is the form:
Code:
<html>
<head>
<title>Guestbook Form</title>
</head>
<body bgcolor="white" text="black">
<!-- Begin form code -->
<form name="form" method="post" action="dataprocess.asp">
<p>Instructor Name:
<input type="text" name="Instructor" maxlength="50">
<br>
Course: <input type="text" name="Course" maxlength="10">
<br>
Session: <input type="text" name="SessionCode" maxlength="10">
<br>
Section: <input type="text" name="Section" maxlength="10">
<br>
Student Name: <input type="text" name="StudentName" maxlength="10">
<br>
Student Competency:
<label>
<select name="StudentComp" id="StudentComp">
<option>1</option>
<option>3</option>
<option>5</option>
</select>
</label>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<!-- End form code -->
</body>
</html>
And here is the asp form.
Code:
<%
' Declaring variables
Dim Instructor, Section, Course, SessionCode, StudentName, StudentComp, data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
Instructor = ChkString(Request.Form("Instructor"))
Course = ChkString(Request.Form("Course"))
SessionCode = ChkString(Request.Form("SessionCode"))
Section = ChkString(Request.Form("Section"))
StudentName = ChkString(Request.Form("StudentName"))
StudentComp = ChkString(Request.Form("StudentComp"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="Server.MapPath("competency.mdb")
sql_insert = "insert into tbl_competency (Instructor, Course_Code, Session, Section, Student_Name, Student_Competency) values ('" & Instructor & "', '" & Course & "', '" & SessionCode & "', '" & Section & "', '" & StudentName & "', '" & StudentComp & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
'Redirect to the guestbook.asp page
Response.Redirect "form.asp"
%>
When I click the submit button, I get a HTTP 500 error and not sure why. Any thoughts?