retrieve data from ms access in asp

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi
Im trying to retrieve data(name, roll no, form no) after I enter roll no. of
some student.
Im using asp & msaccess(database=result06, DSN=msaccess)
what im doing wrong can anyone help me

<form action="result06.asp" method="post" name="form1" target="_parent">
<label>Roll No</label>
<input name="txtroll" type="text" id="txtroll">
<input type="submit" name="Submit" value="Submit">
</form>
<p>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connection.asp" -->
<%
Dim Recordset
Dim Recordset_numRows

Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.ActiveConnection = MM_connection_STRING
Recordset.Source = "SELECT * FROM result06 WHERE txtroll = " & ROLL_NO & " "
Recordset.CursorType = 0
Recordset.CursorLocation = 2
Recordset.LockType = 1
Recordset.Open()

Recordset_numRows = 0
%>
</p>
<p>&nbsp;
</p>

<%
Recordset.Close()
Set Recordset = Nothing
%
<%=(Recordset.Fields.Item("FORM_NO").Value)%><%=(Recordset.Fields.Item("ROLL_NO").Value)%>
 
Snew said:
hi
Im trying to retrieve data(name, roll no, form no) after I enter roll
no. of some student.
Im using asp & msaccess(database=result06, DSN=msaccess)
what im doing wrong can anyone help me

<form action="result06.asp" method="post" name="form1"
target="_parent"> <label>Roll No</label>
<input name="txtroll" type="text" id="txtroll">
<input type="submit" name="Submit" value="Submit">
</form>
<p>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connection.asp" -->
<%
Dim Recordset
Dim Recordset_numRows

Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.ActiveConnection = MM_connection_STRING
Recordset.Source = "SELECT * FROM result06 WHERE txtroll = " &
ROLL_NO & " " Recordset.CursorType = 0
Recordset.CursorLocation = 2
Recordset.LockType = 1
Recordset.Open()

Recordset_numRows = 0
%>
</p>
<p>&nbsp;
</p>

<%
Recordset.Close()
Set Recordset = Nothing
%>
<%=(Recordset.Fields.Item("FORM_NO").Value)%><%=(Recordset.Fields.Item("
ROLL_NO").Value)%>


You don't say what error you're encountering, but it looks to me like
you are closing your recordset before you try extract any value from it.
I see this:

<%
Recordset.Close()
Set Recordset = Nothing
%>

And then I see this:


<%=(Recordset.Fields.Item("FORM_NO").Value)%><%=(Recordset.Fields.Item("
ROLL_NO").Value)%>

I'd think you'd want those in the opposite order.
 
Hi thanks

I did that too but no result there is no error but i dont get the result.
I have made this connection in dreamweaver.
 
Snew said:
Hi thanks

I did that too but no result there is no error but i dont get the
result. I have made this connection in dreamweaver.

All I can think of then is that your query is returning an empty
recordset. I don't know your table, of course; what fields are in the
table named "result06", and what are their data types? You seem to be
expecting you recordset to return fields named "FORM_NO" and "ROLL_NO".
Is there also a field named "txtroll"? Your query string implies that
there is:

"SELECT * FROM result06 WHERE txtroll = " & ROLL_NO

But that also implies that you have a variable in your VBScript named
"ROLL_NO", and I don't see that defined anywhere. On the other hand,
your input form has a field named "txtroll"; is it possible you've got
the table fields and the form fields mixed up?
 
Back
Top