I am trying to display records called "Title" from the Sections DB table horizontally in the dropdown menu and any related recordsets (connected via secondary key SectionID) called "Title" from the Files DB table vertically and every time I add
while not objRs.eof
objRs.MoveNext
wend
when getting recordsets from the Section DB table I receive Either BOF or EOF is True Error. Otherwise the code below displays random menu (see below) where I can not figure out what File Title belongs to what Section. Any ideas, please help. I am just going in circles now and can not find any solution what so ever.
code:
Sub readItemsFromDatabase
Dim db,q,sql,objRs,rsarr,rsarr
2,p_page_i
d,p_title,
p_sec_id,p
_sec,p_par
ent_id,col
s,max,menu
'The path to database:
db ="Provider=Microsoft.Jet.O
LEDB.4.0;D
ata Source=" & Server.MapPath("DB.mdb")
q = "SELECT sectionid, Title, parentid From Sections Order by sectionid"
Set objRs=Server.CreateObject(
"ADODB.Rec
ordset")
Set sqlobjRs=Server.CreateObje
ct("ADODB.
Recordset"
)
objRs.CacheSize = 25
objRs.CursorType = 3
objRs.LockType = 3
'Opening database --- --
objRs.Open q,db
sql = "Select fileid, title, sectionid From Files Where sectionid = " & objRs("sectionid") & " and Files.DLCId = 4"
sqlobjRs.Open sql,db
if NOT objRs.EOF then
rsarr = objRs.GetRows()
max = Ubound(rsarr,2)
else
max = ""
end if
if NOT sqlobjRs.EOF then
rsarr2 = sqlobjRs.GetRows()
max = Ubound(rsarr2,2)
else
max = ""
end if
'Closing database
row=0
do while(row<=max) 'Looping rows
'Setting variables
menuparentlink = "m" & rsarr(0,row)
p_sec_id = rsarr(0,row)
p_sec = rsarr(1,row)
p_page_id = rsarr2(0,row)
p_title = rsarr2(1,row)
pagelink = "mypage.asp?id=" & p_page_id
p_parent_id = rsarr2(2,row)
if(p_parent_id<>0) then
p_parent_id = "m" & p_parent_id
else
p_parent_id=""
end if
'Making menu item
menu = menu & ""
Response.write("oCMenu.mak
eMenu('" & menuparentlink & "','" &p_parent_id & "','" & p_sec & "','" & pagelink & "')" & vbcrlf)
row = row + 1
loop
objRs.close()
Set objRs = Nothing
sqlobjRs.close()
Set sqlobjRs = Nothing
End Sub
random menu display:
oCMenu.makeMenu('m71','m71
','company
','mypage.
asp?id=297
')
oCMenu.makeMenu('m72','m71
','discipl
ines','myp
age.asp?id
=298')
oCMenu.makeMenu('m73','m71
','library
','mypage.
asp?id=306
')
oCMenu.makeMenu('m74','m71
','gallery
','mypage.
asp?id=309
')
oCMenu.makeMenu('m75','m71
','web','m
ypage.asp?
id=310')
oCMenu.makeMenu('m76','m71
','marketi
ng','mypag
e.asp?id=3
14')
oCMenu.makeMenu('m77','m71
','section
','mypage.
asp?id=351
')
oCMenu.makeMenu('m79','m71
','test','
mypage.asp
?id=352')
oCMenu.makeMenu('m80','m71
','The Project','mypage.asp?id=35
3')
oCMenu.makeMenu('m81','m71
','Project
Management','mypage.asp?id
=354')