Skip to main content
Participating Frequently
April 13, 2010
Question

ASP trouble

  • April 13, 2010
  • 1 reply
  • 677 views

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>

This topic has been closed for replies.

1 reply

Participating Frequently
April 14, 2010

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

Luban22Author
Participating Frequently
April 15, 2010

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 &>

Participating Frequently
April 15, 2010

You put the path to the script that processes the form into the form tag action propert.