Results 1 to 6 of 6
Apr 20, 2011, 06:32 #1
- 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:
Here is the ASP page that processes the form:
<%@ Language="VBScript" %> <% Option Explicit %> <html> <head> <title>Form to database</title> </head> <body> <% '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 connection.Open(sConnString) 'execute the SQL connection.execute(sSQL) response.write "The form information was inserted successfully." 'Done. Close the connection object connection.Close Set connection = Nothing
Last edited by Mittineague; Apr 22, 2011 at 14:23. Reason: reformatting bbcode tags