473,761 Members | 8,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in Returning Recordset in ASP

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="Micros oft FrontPage 5.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<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("t xtTbl")
rs = con.execute("se lect count(*) from "&tbl)
end function

public function returnRS
tbl = Request.Form("t xtTbl")
rs1 = con.execute("se lect * from "&tbl)
end function

end class

dim obj
set obj = new AddNum

obj.showRecordC ount
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="#1 11111" width="248" height="52"
id="AutoNumber1 ">
<tr>
<td width="114" height="52">Add ition Of Two Number using Object</
td>
<td width="128" height="52"><in put type = text name = txtAdd
size="20" value = <%=a%>></td>
</tr>
</table>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-
collapse: collapse" bordercolor="#1 11111" width="48%"
id="AutoNumber2 ">
<tr>
<td width="33%">Col umn1 </td>
<td width="33%">Col umn2</td>
<td width="34%">Col umn3</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

Apr 12 '07 #1
1 3566
vi******@gmail. com 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("t xtTbl")
rs = con.execute("se lect 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("t xtTbl")
rs1 = con.execute("se lect * 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.showRecordC ount
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.Fo rm("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.showRecordC ount(con,sTbl)

Set rs = obj.returnRS(co n, 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"
Apr 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1730
by: david | last post by:
Hi I have written code in ASP for paging records from the database (SQL Server 2000). The real problem I have around 10,000 records and it tries to fetch all the records everytime (I'm saying because its take a lot time to display it). Even though, it displays all the data correctly and you can also navigate through links. Is it possible to set the limit on recordset while it fetches the data. Lets say page size is 20 records per
4
5330
by: Eli Sidwell | last post by:
Trying to return a Recordset to an ASP and the Recordset is empty. The StorredProc works in the query analyzer and it even works from a quick VB app that I wrote to test it. The storedproc that I am using is fairly complex (creates some temporary tables and populates them with 'Insert Into Select ...', but the during testing the only Select statements that return visible rows is the final one that returns the finished table with an...
4
1909
by: Ola Tuvesson | last post by:
I'm having a really weird problem. When running the SP below in query analyzer the calculated column "Subscribed" is returned as expected: ------------- CREATE PROCEDURE get_mailinglists( @intCustomerID AS int ) AS
5
3636
by: msprygada | last post by:
I am having a problem with getting a recordset to fill with data in an Access Data Project from a SQL Server database. Here is the code example that is in the Access help files that I can get to work just fine: Dim Cnxn As ADODB.Connection Dim rstEmployees As ADODB.Recordset Dim strCnxn As String Dim strSQLEmployees As String
6
6555
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
4
1434
by: Win | last post by:
Dear All, I am going to change the coding from ASP & VB6 to ASP.Net and VB.Net. However, there is no data retrieved after I changed the coding. Is there anything wrong? Thanks ================================================ VB6 coding
22
12490
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
1
1325
by: vinodkus | last post by:
vinod...@gmail.com wrote: Please stop shouting. Total records?? I think (hope) you mean "count of the total records". In
3
6667
rsmccli
by: rsmccli | last post by:
Access 2002 Hi. I have a command button that will "approve" all records currently being looked at by an "approver". For some reason, even though there are multiple records that exist in the recordsetclone, EOF is returning true. I think this may have something to do with the sort order of the underlying query, but I'm not sure; at any rate, I don't want to change the sort order. I thought you had to check for BOF and EOF, or at least EOF before...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.