Copy link to clipboard
Copied
Hi there
Im no that famliar with ASP. Im creating a simple quiz using ms access. Ive saved 10 questions with 4 possible answers. I want this to show up in my website. i cant seem to get it working.heres the code.any ideas?
thanks
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="Quiz" Type="Submit" Method="get" action="results.asp" >
<p>
<%
Dim MyConn
Dim SQL
Dim RS
Dim i
set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "DSN=myData"
SQL = "SELECT * FROM Quiz.accdb"
Set RS = MyConn.Execute(SQL)
i = 1
do while not RS.EOF
Response.Write RS("Question")
Response.Write(RS("A")&":<input type='radio' name='Question" & i &" 'value='A'><br>")
Response.Write(RS("B")&":<input type='radio' name='Question" & i &" 'value='B'><br>")
Response.Write(RS("C")&":<input type='radio' name='Question" & i &" 'value='C'><br>")
Response.Write(RS("D")&":<input type='radio' name='Question" & i &" 'value='D'><br>")
i = i + 1
RS.MoveNext
loop
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>
<br />
<input type="Submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Copy link to clipboard
Copied
Greetings,
It looks like you are missing an ADO recordset object.
Have a look at this tutorial:
http://www.webwizguide.com/kb/asp_tutorials/connecting_to_a_database.asp
HTH
-Rob B
Copy link to clipboard
Copied
Thanks for the tutorial Rob.This is my code now but it still dont seem to work. what do i have to put in the action="" part? here is my code now: any ideas what the problem is?
thanks again
<body>
<form name="Quiz" Type="Submit" Method="get" action="what do i put in here" >
<p>
<%
Dim MyConn
Dim strSQL
Dim RSQuiz
Dim i
set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "DSN=Quiz"
Set RSQuiz=Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Quiz"
RSQuiz.Open strSQL,MyConn
Set RSQiiz = MyConn.Execute(SQL)
i = 1
do while not RSQuiz.EOF
Response.Write RS("Question")<br>
Response.Write(RSQuiz("A")&":<input type='radio' name='Question" & i &" 'value='A'>")<br>
Response.Write(RSQuiz("B")&":<input type='radio' name='Question" & i &" 'value='B'>")<br>
Response.Write(RSQuiz("C")&":<input type='radio' name='Question" & i &" 'value='C'>")<br>
Response.Write(RSQuiz("D")&":<input type='radio' name='Question" & i &" 'value='D'>")<br>
i = i + 1
RSQuiz.MoveNext
loop
RSQuiz.Close
MyConn.Close
Set RSQuiz = Nothing
Set MyConn = Nothing
&>
<br />
<input type="Submit" name="Submit" value="Submit">
</p>
</form>
</body>
this is the result im getting on screen:
<% Dim MyConn Dim strSQL Dim RSQuiz Dim i set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open "DSN=Quiz" Set RSQuiz=Server.CreateObject("ADODB.Recordset") strSQL = "SELECT * FROM Quiz" RSQuiz.Open strSQL,MyConn Set RSQiiz = MyConn.Execute(SQL) i = 1 do while not RSQuiz.EOF Response.Write RS("Question")
Response.Write(RSQuiz("A")&":")
Response.Write(RSQuiz("B")&":")
Response.Write(RSQuiz("C")&":")
Response.Write(RSQuiz("D")&":")
i = i + 1 RSQuiz.MoveNext loop RSQuiz.Close MyConn.Close Set RSQuiz = Nothing Set MyConn = Nothing &>
Copy link to clipboard
Copied
You put the path to the script that processes the form into the form tag action propert.
Copy link to clipboard
Copied
You have a mis-spelling on this line:
Set RSQiiz = MyConn.Execute(SQL) 'RSQuiz
If your asp code is echoing out to the browser, either your server doesn't handle asp code or the file you have put this code in is not named 'yourfilename.asp', the .asp file extension is necessary for the server to recognize the asp code, unless you have configured the server otherwise.
HTH
-Rob B
Copy link to clipboard
Copied
>this is the result im getting on screen:
Ah, I completely missied that in your post. 00rDog is correct. It looks like either your server does not run ASP (is it a Windows server?) or your page has the wrong extension.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more