Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2010, 04:22 PM
Authorized User
 
Join Date: Aug 2006
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not sure why the form isn't submitting

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?
 
Old April 1st, 2010, 06:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

First of all, this is an ASP.NET forum, and your post seems to be related to classic ASP. To attract more attention, consider posting in a class ASP forum: http://p2p.wrox.com/asp-net-asp-12/

That said, a 500 error is a generic error. Try getting the real error message. In IE, try Tools | Advanced, and then disable Friendly Error Messages...

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
form submitting cro_crx Pro PHP 5 January 25th, 2005 12:19 PM
Form Submitting cro_crx Beginning PHP 3 January 17th, 2005 01:30 PM
Submitting a form YuliaKupina Classic ASP Basics 3 June 24th, 2004 01:52 AM
Chapter 3, submitting a form YuliaKupina BOOK: Beginning ASP 3.0 1 June 23rd, 2004 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.