?
Solved

Need Help with Form to File Script

Posted on 1998-09-14
11
Medium Priority
?
269 Views
Last Modified: 2013-12-25
Hi,

I have to conduct a web survey next week and need the responses inputed into a MS Access database. The webserver is on a Windows NT machine with ASP components installed. I'm pretty familiar with HTML and slightly familiar with Perl scripts (using them, not coding) but am entirely new to ASP. Please help.

Thanks,

Priyo
0
Comment
Question by:irina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1828624
Supposing you have the HTML form for the survey and the Access database to store the result, both ready, it is quite easy to make the ASP.
My suggestion is that you post the HTML-form and the structure of the database. There are several people here visiting daily that can create the ASP for you and post it here.

0
 

Author Comment

by:irina
ID: 1828625
Hi,

The HTML form can be seen here: http://members.tripod.com/~kdsa/survey.htm
The Access Database can be found here: http://members.tripod.com/~kdsa/survey.mdb

The access database has three fields -- fields 1 (question 1) and 2 (question 2) are number fields while field 3 (question 3) is for text responses (I've set the character length at 255, the max).  I've filled in the contents of the fields for one record -- the coding is as follows:
SA - 5
A - 4
U - 3
D - 2
SD - 1

Thanks.

0
 
LVL 28

Expert Comment

by:sybe
ID: 1828626
I could not download the database, so I made one myself.
I have got it working.

You can download the file from
ftp://195.240.30.16/EE/
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

Author Comment

by:irina
ID: 1828627
Hi,

I tried it -- it didn't work.  What specific ASP components does this require? I have to check with the sysadmin to make sure that we have them installed.

Thanks,

Priyo
0
 
LVL 28

Expert Comment

by:sybe
ID: 1828628
Sorry, I think it needs some explanation, which I forgot:

You have to make an ODBC-connection on the machine with the webserver.

I'll step through the code and explain it:

(update.asp)
==============
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=survey"
==============

This piece of code makes a connection to the database.
The name of the connection is "Conn" which is a pretty default name, but you can use any name you want.

The first line "creates" a connection object.

The second line gives the connection object a value. The value is related to the ODBC name of the database.
What I have done (and what you should do) is create an ODBC to the survey database. This can be done using Control Panel / OBDC32 / System DSN / Add

Select driver: MS Access /finish

Then give it a name (remember this name, I called it "survey", and that is what I use in the ASP-statement), and select the database.

=======================
strSQL = "INSERT INTO survey (question1, question2, comment ) values (" & Request.Form("question1") & "," & Request.Form("question2") & ",'" & REPLACE(Request.Form("comment"),"'","''") & "')"

Response.write strSQL
========================

The strSQL is a variable that makes up the SQL statement for the database. If you are familiar witrh SQL then you should understand, if not, just believe me

Response.write strSQL is not important, in fact it only write the SQL statement to the browser, I put that in to check for any errors. Leave it out, because it is ugly.

=============
Conn.Execute(strSQL)
=============
Will send the strSQL to the database through the ODBC connection. In the database the SQL statement is carried out.



Probably the only thing you should do is create the ODBC
---------------------------------

0
 

Author Comment

by:irina
ID: 1828629
Sorry, I don't have access to the control panel.
0
 
LVL 28

Expert Comment

by:sybe
ID: 1828630
??

Then let someone else do it for you, if you "have to" then it seems logical that someone should do for you what you are not allowed to do personally.

You can however make a connection without creating an ODBC, I'll have to find that out.


0
 

Author Comment

by:irina
ID: 1828631
Sorry if I sounded brusque but we're in a bind -- basically, we have to get something done with very little help (and a whole lot of obstacles) from the Computing Center here.

Thanks for your effort.
0
 
LVL 1

Expert Comment

by:alweiner
ID: 1828632
Lets say you've got variables a,b,c,d

<form action="tricky.asp" method="post">
... I assume you know how to do a form
</form>

In tricky.asp (note: comments begin with a single quote):
<HTML>
<BODY>
<%
' get the data from the form
a0=request.form("a")
b0=request.form("b")
c0=request.form("c")
d0=request.form("d")
'
' Open a text file and append the data to it
set filesys=CreateObject("Scripting.FileSystemObject")
'
' Note: you can call the file anything you want, however,
' you will need to find a directory where you can write a file
' and put the path of that directory as part of the filename
set f=filesys.OpenTextFile("output.txt",ForAppending,true)
f.WriteLine a0 & "," & b0 & "," & c0 & "," & d0
f.Close
set f=nothing
set filesys=nothing
%>
Thank you for sending us your data!
</body>
</html>
'======= end of tricky.asp don't include this line =====

When people are done entering the data, you can import the
data from the ascii file into the access database.  The
advantage to this is, you don't have to worry about ODBC or
any of that setup stuff...
0
 

Author Comment

by:irina
ID: 1828633
hi,

I'd appreciate some more detailed information. Should the asp file be different from the HTML form, etc.?
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 800 total points
ID: 1828634
Using Sybes marvelous example, I adapted it a little... You don't have to create a DSN at the control panel... You can do it dynamically...

Use this:

<!-- #include Virtual="/YourVirtualDir/TDSN.Asp" -->
Place this tag at the top of every page you want to access the database with (ie the UPDATE.ASP page)

---------------------------------- TDSN.ASP File ---------------
<%
  Dim sDB, sPath, sDSN, sScriptDir

  sDB   = "survey.mdb"  ' Your database name

  sScriptDir = "/VirtualDirToDatabase" ' Virtual Directory to Database

  ' Set the virtual Directory
  sPath = Server.MapPath(sScriptDir) & "\"

  ' This is the resulting DSN string
  sDSN = "filedsn=" & sPath & "GoldenPlates.Dsn;DefaultDir=" & sPath & ";DBQ=" & sPath & sDB & ";"
%>

Now, where Sybe said to use Conn.Open "DSN=Survey" use this instead...
Conn.Open sDSN

You can then access the database...

Please split the points between Sybe and I.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question