Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Horizontal recordset
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  00:59:48  Show Profile  Visit TastyNutz's Homepage
I want to display a recordset in a table with x number of records in a row. I have tried a code example found HERE. But it gives a "loop without do" error. I've followed the example exactly, but can't make it work.

Can anyone help me out?


PowerQuad Disability Support Forum

cripto9t
Average Member

USA
881 Posts

Posted - 14 November 2007 :  07:47:11  Show Profile
Looks like big chunk of that is missing

I rearranged it to use getRows
This isn't tested

<!--#INCLUDE VIRTUAL="/includes/connection.asp" -->

<%
DIM mySQL, objRS, recCount
mySQL = "SELECT col1, col2 FROM tblData" 
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.open mySql, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText

if objRS.EOF then
	recCount = ""
else
	allData = rs.GetRows(adGetRowsRest)
	recCount = UBound(allData,2)
end if

objRS.close
set objRS = nothing

if recCount <> "" then
        DIM intMarker,intItems,strStartRow,strEndRow

        intItems = 3  '###  You Set number of rows per row

        Response.Write "<table width=""100%"">"

        For intMarker = 0 to recCount

                col1 = allData(0,intMarker)
                col2 = allData(1,intMarker)

                if intMarker Mod intItems = 0 then
                        strStartRow = "<tr>"
                        strEndRow ="</tr>"
                else
                        strStartRow = ""
                        strEndRow =""
                end if
                Response.Write  strStartRow & "<td>" & col1 & "</td><td>" & col2 & </td>" & strEndRow

                if (intMarker = recCount) and (recCount mod intItems <> 0) then Response.Write  "</tr>"
        next

        Response.Write  "</table>"
ELSE
        Response.Write "Sorry, there are no records in our database."
END IF
%>

    _-/Cripto9t\-_

Edited by - cripto9t on 14 November 2007 07:50:08
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  08:27:26  Show Profile  Visit TastyNutz's Homepage
quote:
Originally posted by cripto9t

objRS.open mySql, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText



"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another"





PowerQuad Disability Support Forum
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  12:37:28  Show Profile  Visit TastyNutz's Homepage
Okay Marshal, getting closer! But the display is not showing the 2nd and 3rd record on each row.

See HERE


PowerQuad Disability Support Forum
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  13:18:40  Show Profile  Visit TastyNutz's Homepage
Got it!


<%
	'Database connection string
	cnProvider = "Provider=Microsoft.JET.OLEDB.4.0;"
	cnDataSource = "Data Source="&Server.MapPath("database\mydatabase.mdb")
	Conn = cnProvider & cnDataSource


DIM mySQL, objRS
mySQL = "SELECT * FROM tblData" 
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, Conn
DIM recCount
IF Not objRS.EOF THEN
  Response.Write "<table width='100%' border='1'>"
  recCount = 0
  Do UNTIL objRS.EOF
    IF recCount Mod 3 = 0 THEN
	    Response.Write "<tr>"
    END IF

        Response.Write "<td>"&objRS("Item")&"</td>"
	IF recCount = recCount - 1 THEN
	    Response.Write "</tr>"
		
    END IF
    recCount = recCount + 1
	
    objRS.MoveNext
  Loop
		Response.Write"</tr></table>"
ELSE
  		Response.Write "Sorry, there are no records in our database."
END IF

%>


Thanks guys.


PowerQuad Disability Support Forum
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07