Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need recordset to move to next line after each record

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
CA
Hi,

this is my code to display all records in a sql database
<%
Do Until QueryDB.EOF
Response.Write(QueryDB.Fields.Item(&quot;ProductMake&quot;).Value)
Response.Write(QueryDB.Fields.Item(&quot;ProductDescription&quot;).Value)
QueryDB.MoveNext
Loop
%>

Pretty basic. My problem is I need each record to be displayed on its own line. Right now, all records appear on the same line until the screen wrap around. Hope this makes sense.. Any suggestions?

This is what gets returned..

Sony 21&quot; Trinitron Sony 22&quot; Trinitron Sony 48&quot; Trinitron

I need

Sony 21&quot; Trinitron
Sony 22&quot; Trinitron etc..

Thanks for the help!

 
<%
Do Until QueryDB.EOF
Response.Write(QueryDB.Fields.Item(&quot;ProductMake&quot;).Value)
Response.Write &quot;<br>&quot;
Response.Write(QueryDB.Fields.Item(&quot;ProductDescription&quot;).Value)
QueryDB.MoveNext
Loop
%>

OR better solution for 2 columns:
use rs.GetString
String = recordset.GetString(StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr)

strTable = rs.GetString(,,&quot;</td><td>&quot;,&quot;</td></tr><tr><td>&quot;,&quot;&nbsp;&quot;)
Response.Write strTable
 
not quite sure but it really sounds like all you need is a line break <br>
<%
Do Until QueryDB.EOF
Response.Write(QueryDB.Fields.Item(&quot;ProductMake&quot;).Value)
Response.Write(QueryDB.Fields.Item(&quot;ProductDescription&quot;).Value)
Response.Write(&quot;<br>&quot;)
QueryDB.MoveNext
Loop
%>
_______________________________________________
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
 
Thanks for your updates guys.. it works

However, 777axa has an interesting idea which I would like to try, splitting the results into columns?? I tried the example (getstring) but had no luck

ANy other ideas?
 
Ok, heres a breakdown of the GetString function:
Code:
.GetString(format, numRows, columnDelimiter, rowDelimiter, nullReplacement)
All of these are optional. Format only has one possible value, which is 2 (adClipString) which basically tell the function to use the delimiter values.
numRows is the number of rows in the recordset to process.
Column and Row delimiter should be obvious.
nullReplacement is what gets placed in the string when it runs into fields with nulls in it. I would suggest something like &amp;nbsp;

Hope this helps,
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
THanks

How about excluding certain columns from the Getstring command. I'm having all columns returned.

<%
strTable = QueryDB.GetString(,,&quot;</td<td>&quot;,&quot;</td><tr><td>&quot;,&quot; &quot;)
Response.Write strTable
%>

Not sure if thats right, but I would like only 4 out of the 6 columns in the database returned to ASP. Also, one of those columns is to be a URL to an image.

ANy suggestions?

Thanks for the help
 
OR

Can I have the results spread across a table of 4 columns on the page... That way it will look a little more arranged and presentable?

 
Change your select statement. i.e. don't use SELECT * FROM table, but SELECT field1, field2, field3, field4 FROM table

777axa, I thought I know ASP but I have never used this GetString method. Shame! Thanks for the tip. :)
 
HI,

This is my code to return 4 columns of information.
When it's returned to the screen, it looks OK except I would like to maintain some formation. Example

This is what I get:

Duracell AABattery 24.99
Energizer AAABattery 35.99
Cheap AABattery 10.99

I would like

Duracell AABattery 24.99
Energizer AAABattery 35.99
Cheap AABatery 10.99

<%
Response.Write &quot;<BR>&quot;
Do Until QueryDB.EOF%>
<img src=&quot;<%=QueryDB(&quot;ImageLoc&quot;)%>&quot; width=&quot;75&quot; height=&quot;75&quot;&quot;>
<%
Response.Write(QueryDB.Fields.Item(&quot;ProductType&quot;).Value)
Response.Write(QueryDB.Fields.Item(&quot;ProductMake&quot;).Value)
Response.Write(QueryDB.Fields.Item(&quot;ProductDescription&quot;).Value)
Response.Write &quot;Your Price Only $&quot;
Response.Write(QueryDB.Fields.Item(&quot;SalePrice&quot;).Value)
Response.Write &quot;<BR>&quot;
QueryDB.MoveNext
Loop
%>

Any IdeaS?
 
1.
Try to put each Response.Write(QueryDB.Fields(&quot;ProductDescription&quot;))
into separate column of the table.
If you are using DW - repeat that row.
<tr>
<td><%=(QueryDB.Fields(&quot;ProductType&quot;))%></td>
<td><%=(QueryDB.Fields(&quot;ProductMake&quot;))%></td>
<td><%=(QueryDB.Fields(&quot;ProductDescription&quot;))%></td>
<td><%=(QueryDB.Fields(&quot;ProductPrice&quot;))%></td>
</tr>

2.
GetString method is very good for displaying large amount of data without overloading your server.
Try to display 50-100 records consisting of 5 columns by using Response.Write and you'll see how slow it is. It is like going to the store again and again for each item instead of putting everything you need in the basket in one trip.
So for displaying 50 records of 5 fields you'll need 250 trips to the server plus 50 trips for EOF checking & 50 for rs.MoveNext ~ 350
3.
Another fast method is GetRows but you'll have to use a bit of looping & arrays
 
Hi 777axa

U mentioned if using DW repeat that row - I didn't quite understand that. I am using dreamweaver. I have tried placing a <td> before each response.write and now my display seems to be adding a new <td> everytime it loops (hope that makes sense.)

But in general, I'm getting all results on the same row.
I need the results spread across 2 columns and new rows if needed.

Currently:

Result1 Result2 Result3 Result4

I Need

Result1 Result2
Result3 Result4

Hope this makes sense... but here is a sample of my code right now..

<%Response.Write &quot;<BR>&quot;
Do Until QueryDB.EOF%>
<td width=&quot;75&quot;><img src=&quot;<%=QueryDB(&quot;ImageLoc&quot;)%>&quot; width=&quot;75&quot; height=&quot;75&quot;&quot;></td>
<td width=&quot;17&quot;><%=(QueryDB.Fields(&quot;ProductType&quot;))%></td>
<td width=&quot;471&quot;><%=(QueryDB.Fields.Item (&quot;ProductMake&quot;).Value)%></td>
<%Response.Write &quot;<BR>&quot;
QueryDB.MoveNext
Loop
%>

Thanks
 
should be very easy to do:

<table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td><%=(QueryDB.Fields(&quot;Product1&quot;))%></td>
<td><%=(QueryDB.Fields(&quot;Product2&quot;))%></td>
</tr>
<tr>
<td><%=(QueryDB.Fields(&quot;Product3&quot;))%></td>
<td><%=(QueryDB.Fields(&quot;Product4&quot;))%></td>
</tr>
</table>

Select both <TR>'s (everything between TABLE tags) and apply Repeat Region behavior...

Are you new to ASP and DW MX?
 
Yes I am new to ASP and DWMX guess it wasn't hard to figure that out!!

Thanks for your help really appreciated
 
Thanx 777axa you been a great help..

and last but not least :) I need the next record to be displayed, in another column. (there are two products with the same product type I would like them displayed beside each other.

eg

Batteries Batteries
AAA Battery AA Battery

I currently get

Batteries
AA Battery

Batteries
AAA Battery

Not sure if I explained it right, as you can see from the code, I have repeated some response.writes to display information in a column beside it, however, it seems to be the same info from the 1st column. I would like the next record to appear beside it.

<tr>
<%Do Until QueryDB.EOF%>
<td>&nbsp;<img src=&quot;<%=QueryDB(&quot;ImageLoc&quot;)%>&quot; width=&quot;50&quot; height=&quot;50&quot;&quot;></td>
<td><%=(QueryDB.Fields(&quot;ProductType&quot;))%></font></td>
<td><%=(QueryDB.Fields(&quot;ProductDescription&quot;))%><%=&quot;<br>&quot;%>
<%=(QueryDB.Fields(&quot;SalePrice&quot;))%></font></td>
<td>&nbsp;<img src=&quot;<%=QueryDB(&quot;ImageLoc&quot;)%>&quot; width=&quot;50&quot; height=&quot;50&quot;&quot;></td>
<td><%=(QueryDB.Fields(&quot;ProductType&quot;))%></font></td>
<td><%=(QueryDB.Fields(&quot;ProductDescription&quot;))%><%=&quot;<br>&quot;%>
<%=(QueryDB.Fields(&quot;SalePrice&quot;))%></font></td>
</tr><%QueryDB.MoveNext%>
<%Loop%>

Thanks folks!
 
find MW extension called Horizontal Looper 2 (as I remember).
it will do the job.

Also I'd recommend buying a good book on ASP (I have several and they help me every day)
And the last thing - go & try different ASP software.
DM writes ASP code in not the most efficient way and sometimes it is hard to understand for beginner.

I think that CodeCharge and CodeCharge Studio are the the best (complimentary to DW) ASP RAD tools. ASP code is separated from HTML pages, all functions and subs are in different modules and you can compile them in DLLs in CCS.
CC & CCS are great for creating the &quot;back ends&quot; really fast.
You can learn more professional style coding by studying what CC & CCS do and use DW just for design part afterwards.

Finally, after several good books & projects try VS.NET
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top