473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SQL statement only returns 1 row instead of 60+

I have an access db with 60+ records in a table, I am trying to display the records on a page. At this point, I am able to connect to the db, but I can only get the first record within the recordset.

I've tried everything I can think of, so I'm hopeing someone with a fresh mind can review and see what I'm doing wrong.

[code begins here]
<%
Dim conn, rs, DBPath

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../db/login.mdb") & ";"
Set rs = Server.CreateObject("ADODB.RecordSet")

'Set SQL
rsStr = "SELECT title, fname, lname From userinfo"

rs.open rsStr, conn

'This is to display the results from the SQL String
Response.Write "There are " & rs.recordcount & " rows that were returned"

for each x in rs.Fields
Response.Write(" ")
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "")
next

rs.close
set rs=Nothing
conn.close
set conn = nothing
%>
[/code]

Thanks in advance for all your help!
Sep 16 '06 #1
2 1726
Hi ,

Let the number of rows returned is 60.

Response.Write "There are " & rs.recordcount & " rows that were returned"
Is the above statement returning correct result,in this case 60?
If it returns correct result, then the problem is with for loop.

Instead of using for loop, u just try these below statements,
Expand|Select|Wrap|Line Numbers
  1. If not rs.eof then
  2.  do until rs.eof
  3.   response.write(rs.fields(0) & "," & rs.fields(1)) 'suppose two columns are there
  4.  rs.movenext
  5.  loop
  6. end if
  7.  
I hope this code works.

Thanks & Regards,
Jaya.S
mail to: jayadevi.s@tcs.com
Sep 18 '06 #2
Hi Jaya!

To answer your question, the
Response.Write "There are " & rs.recordcount & " rows that were returned"
is only reporting that 1 record is in the record set. But the sample loop that you provided is displaying all 60+ records! Horray!

Thanks again for your help!

Michelle
Sep 19 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
5
by: Wing | last post by:
Hi all, I am writing a function that can change the value "Quantity" in the selected row of MS SQL table "shoppingCart", my code is showing below ...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
3
by: Assembly file locked | last post by:
I'm trying to put a SQL statement in a web.config file. But I'd like to have a customized column name as I normally do in ORACLE: e.g. select reg_date "Registration" from patient But when I...
6
by: Kbalz | last post by:
Trying to run a simple query on my dataset the SQL statement looks like this: select * from person where id in (@p) When using more than one id in the "in statement", I get...
4
by: daxco21 | last post by:
I have been working on this simple project for a week, and come to the point where I feel like I need outside help. For the life of me I can't figure out what is wrong with this "sellIceCream(...)"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...

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.