SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    0 Post(s)
    0 Thread(s)

    Need help writing to MS Access DB

    I'm still learning ASP so please bare with me on this.
    I'm trying to write a customer satifaction survey so I need to pass the survey results to an MS Database. The problem is that no user data is being written into the db. But blank records are being written. I'm not sure what went wrong here. Can someone provide some assistance with this? I assume it's an easy fix.

    This is the HTML page with the form data:
    HTML Code:
          <title>New Customer Survey </title>
    <script language="javascript">
    function ClearForm() {
      document.surveyForm.q2.value= "";
    function ClearQ3() {
      document.surveyForm.q3.value= "";
    function ClearQ4() {
      document.surveyForm.q4.value= "";
         <p align=center> <img src=images/banner.jpg></p>
         <form name=surveyForm meathod=POST action=getsurvey.asp>
             <table border=1 align=center>
                   <td>1. Do you remember the Tech that you spoke to regarding your problem?</td>
                               <option value="select">--Select Answer--</option>
                               <option value="Yes">Yes</option>
                               <option value="No">No</option>
                           <td>2. Overall, how do you feel the Tech Support Representative handled your issue?</td>
                           <td><input type=text name=q2 value="Enter a number 1-5" onfocus="ClearForm();">
                           <td>3. Do you feel that your issue was acknowledged within timely manner?</td>
                           <td><input type=text name=q3 value="Enter a number 1-5" onfocus="ClearQ3();"</td>
                             <td>4. Do you feel that your issue was acknowledged within timely manner?</td>
                             <td><input type=text name=q4 value="Enter a number 1-5" onfocus="ClearQ4();"</td>
                           <p align=center><input type=Submit value="Submit Survey"></p>

    Here is the ASP page that processes the form:
    Code ASP:
    <%@ Language="VBScript" %>
    <% Option Explicit %>
    <title>Form to database</title>
    'declare your variables
    Dim ques2, ques3, ques4
    Dim sConnString, connection, sSQL
    'Receiving values from Form, assign the values entered to variables
    ques2 = Request.Form("q2")
    ques3 = Request.Form("q3")
    ques4 = Request.Form("q4")
    'declare SQL statement that will query the database
    sSQL = "INSERT into survey (Question2, Question3, Question4) values ('" & _
    ques2 & "', '" & ques3 & "', '" & ques4 & "')"
    'define the connection string, specify database
    'driver and the location of database
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("data/survey.mdb")
    'create an ADO connection object
    Set connection = Server.CreateObject("ADODB.Connection")
    'Open the connection to the database
    'execute the SQL
    response.write "The form information was inserted successfully."
    'Done. Close the connection object
    Set connection = Nothing
    Last edited by Mittineague; Apr 22, 2011 at 14:23. Reason: reformatting bbcode tags


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts