Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Problem in Returning Recordset in ASP

Reply
Thread Tools

Problem in Returning Recordset in ASP

 
 
vinodkus@gmail.com
Guest
Posts: n/a
 
      04-12-2007
I M BEGINNER IN ASP
I WANT TO RETURN TOTAL RECORDS FROM A TABLE.
THERE ARE TWO FORMS CLASS1.ASP AND CLASS2.ASP
THROUGH FIRST FORM I JUST POST THE NAME OF TABLE
SO I M WRITING THE CODE OF CLASS2.ASP

<!--#Include File = "Include/iecon.inc"-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<%
dim rs,rs1

class AddNum

public function showRecordCount()
tbl = Request.Form("txtTbl")
rs = con.execute("select count(*) from "&tbl)
end function

public function returnRS
tbl = Request.Form("txtTbl")
rs1 = con.execute("select * from "&tbl)
end function

end class

dim obj
set obj = new AddNum

obj.showRecordCount
Response.write("<br>")

Response.write ("Total Record is " & rs(0))
%>

<div align="left">
<table border="1" cellpadding="0" cellspacing="0" style="border-
collapse: collapse" bordercolor="#111111" width="248" height="52"
id="AutoNumber1">
<tr>
<td width="114" height="52">Addition Of Two Number using Object</
td>
<td width="128" height="52"><input type = text name = txtAdd
size="20" value = <%=a%>></td>
</tr>
</table>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-
collapse: collapse" bordercolor="#111111" width="48%"
id="AutoNumber2">
<tr>
<td width="33%">Column1 </td>
<td width="33%">Column2</td>
<td width="34%">Column3</td>
</tr>
<%
obj.returnRS
if not rs1.eof then '/*********LINE NO 66 *****************/
while not rs1.eof
%>
<tr>
<td width="33%"><%=rs1(0)%> &nbsp;</td>
<td width="33%"><%=rs1(1)%> &nbsp;</td>
<td width="34%"><%=rs1(2)%> &nbsp;</td>
</tr>
<%
rs1.movenext
wend
end if
%>
</table>
</body>
</html>

MY ERROR IS
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'eof'
/vkasp/aspClass/class2.asp, line 66

BUT WHEN I COMMENT THE IF AND WHILE LOOP PROCEDURE IT GIVES THE FIRST
RECORD BUT I WANT ALL RECORD FROM TABLE.
WHAT IS PROBLEM
PLEASE HELP ME
THANKS

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-12-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I M BEGINNER IN ASP


Please stop shouting.

> I WANT TO RETURN TOTAL RECORDS FROM A TABLE.
> THERE ARE TWO FORMS CLASS1.ASP AND CLASS2.ASP


Total records?? I think (hope) you mean "count of the total records". In
ASP, unless you have some means to limit the number of rows in a table, you
should never be thinking about retrieving all the records in a table. Always
use a WHERE clause to limit your results. If that is not possible, use the
TOP n operator.

> THROUGH FIRST FORM I JUST POST THE NAME OF TABLE
> SO I M WRITING THE CODE OF CLASS2.ASP
>

<snip of irrelevant html>

> dim rs,rs1
>
> class AddNum
>
> public function showRecordCount()
> tbl = Request.Form("txtTbl")
> rs = con.execute("select count(*) from "&tbl)



You are missing the "Set" keyword here - you are dealing with an object
variable, not scalar.


> end function


What is this function supposed to do? Simply open the recordset and assign
it to the global rs variable? If so, why use a function? A sub would be more
suited for this given that you aren't returning any values from the
procedure.

>
> public function returnRS
> tbl = Request.Form("txtTbl")
> rs1 = con.execute("select * from "&tbl)


Again, you are missing the "Set" keyword here - you are dealing with an
object variable, not scalar.

> end function


Again, a function that does not return anything! This is bizarre. Also, the
misguided use of selstar! ALWAYS (my turn to shoult) specify the names of
the fields you wish to retrieve. http://www.aspfaq.com/show.asp?id=2096

>
> end class
>
> dim obj
> set obj = new AddNum


>
> obj.showRecordCount
> Response.write("<br>")
>
> Response.write ("Total Record is " & rs(0))

<snip of irrelevant html>

> <%
> obj.returnRS
> if not rs1.eof then '/*********LINE NO 66 *****************/


<snip of irrelevant html>
>
> MY ERROR IS
> Error Type:
> Microsoft VBScript runtime (0x800A01B6)
> Object doesn't support this property or method: 'eof'
> /vkasp/aspClass/class2.asp, line 66
>
> BUT WHEN I COMMENT THE IF AND WHILE LOOP PROCEDURE IT GIVES THE FIRST
> RECORD


Really? I'm amazed. Without the Set keyword, rs1 should not even be a
recordset. Here is how I would recode this class (I would be passing the
list of field names for the select clause but I won't get into that).

<%
dim rs, sTbl
sTbl=Request.Form("txtTbl") 'only access collections once

class AddNum

public function showRecordCount(con, tbl)
dim rsLocal, sql
sql="select count(*) from " & tbl
set rsLocal= con.execute(sql,,1)
showRecordCount = rsLocal(0)
rsLocal.close
end function

public function returnRS(con, tbl)

dim sql
sql="select * from " & tbl
Set returnRS = con.execute(sql,,1)
end function

end class

dim obj
set obj = new AddNum

Response.write("<br>")

Response.write "Total Record is " & _
obj.showRecordCount(con,sTbl)

Set rs = obj.returnRS(con, sTbl)
'The IF statement is not necessary since you are not
'doing anything (it seems) if EOF is true

Do Until rs.EOF
...
Loop
%>


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
webservice returning dataset (recordset) to visual basic 6 app? =?Utf-8?B?cGF0cmlja2RyZA==?= ASP .Net 4 05-06-2007 08:55 PM
Problem in Returning Recordset in ASP vinodkus@gmail.com ASP General 1 04-14-2007 06:01 PM
Returning RecordSet to ASP is empty Eli Sidwell ASP General 4 02-11-2004 05:23 PM
RecordSet.Move or RecordSet.AbsolutePosition?? Hung Huynh ASP General 8 09-24-2003 11:07 AM
Vb6 object returning ADO Recordset - Error in .NET Developer ASP .Net 0 08-11-2003 03:27 PM



Advertisments