...

View Full Version : Getrows causing me a headache



tcadieux
01-05-2007, 05:07 PM
The below code works fine until i call the BuildLinksArray sub routine. I'm getting the wonderful "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record." error but i've tested my query and it runs fine when i replace the Array variable with an actual number. I also checked and the subRoutine is passing an ID for each of the arrGlossary ?




<!--#include file="../Connections/adovbs.inc" -->
<%
iRecordId=Request.Querystring("id")

If IsNumeric(iRecordId) Then
iRecordId = CLng(iRecordId)
Else
iRecordId = 0
End If

Dim SCRIPT_NAME
SCRIPT_NAME = Request.ServerVariables("SCRIPT_NAME")

Response.write("<A href='"&SCRIPT_NAME&"' class='MoreArmyNewsHeadline'>Display All</A>")
response.write ("&nbsp;<img src=../Images/divider.gif>")
response.write ("<p></p>")

'<--------------------- Get the Glossary Definitions ------------------------->
'Get the Glossary Definitions and store them in an array
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("../Access/Glossary.mdb")

strSQL="SELECT tblGlossary.GlossaryId, tblTerms.Term_e, tblDesc.Desc_e "
strSQL=strSQL & " FROM (tblGlossary INNER JOIN tblTerms ON tblGlossary.TermsId = tblTerms.TermsID)"
strSQL=strSQL & " INNER JOIN tblDesc ON tblGlossary.DescId = tblDesc.DescID"


IF iRecordId<>"0" THEN
strSQL =strSQL & " WHERE tblGlossary.DescID=" & iRecordId
END IF

'response.Write(strSQL)
'response.end

Set cnnGetRows = Server.CreateObject("ADODB.Connection")
cnnGetRows.Open conn

Set rstGetRows = cnnGetRows.Execute(strSQL)
arrGlossary = rstGetRows.GetRows(, adBookmarkCurrent, Array("GlossaryId","Term_e","Desc_e"))

rstGetRows.Close
Set rstGetRows = Nothing
cnnGetRows.Close
Set cnnGetRows = Nothing
'<--------------------- END Get the Glossary Definitions ------------------------->



'<------- Loop through all the Definitions ----------------------->
' IF a Defintion is Found as text in the Article Variable, use the Highlight Function to Add A HREF code to it --->
For I = LBound(arrGlossary, 2) To UBound(arrGlossary, 2)

Response.write ("<table width='450' border='0' cellpadding='0' cellspacing='0'>"& vbCrLf)
Response.write ("<tr>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_topleft.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td width='300' align='left' valign='top' background='../Images/2_0/equip_lines_Top.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td width='120' align='left' valign='top' background='../Images/2_0/equip_lines_Top.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td width='15' background='../Images/2_0/equip_lines_topright.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("</tr>"& vbCrLf)

Response.write ("<tr>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_left.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td align='left' vAlign='top' ColSpan='2'><A Class='SubHeadline'>"&arrGlossary(1,I)&"</A></BR></td>"& vbCrLf)
'Response.write ("<td align='left' valign='top'><div align='center'>gggg</div></td>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_right.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("</tr>"& vbCrLf)

Response.write ("<tr>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_left.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td align='left' vAlign='top' ColSpan='2'></BR>"&arrGlossary(2,I)&"</td>"& vbCrLf)
'Response.write ("<td align='left' valign='top'><div align='center'>gggg</div></td>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_right.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("</tr>"& vbCrLf)

' 'Check and see if there are Related Links ---->
Call BuildLinksArray (arrGlossary(0,I))
' 'END Check and see if there are Related Links ---->

Response.write ("<tr>"& vbCrLf)
Response.write ("<td width='12' height='25' background='../Images/2_0/equip_lines_bottomLeft.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_Bottom.jpg'></td>"& vbCrLf)
Response.write ("<td background='../Images/2_0/equip_lines_Bottom.jpg'><div align='center'>&nbsp;</Div></td>"& vbCrLf)
Response.write ("<td nowrap='nowrap' background='../Images/2_0/equip_lines_bottomRight.jpg'></td>"& vbCrLf)
Response.write ("</tr>"& vbCrLf)
Response.write ("</table>"& vbCrLf)
Response.write ("<p></p>"& vbCrLf)

Next 'I
'<------- END Loop through all the Definitions ----------------------->


Sub BuildLinksArray (theID)

'<--------------------- CHECK FOR LINKS ------------------------->
'Uses the Id of the current Glossary term and check for matching Links
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("../Access/Glossary.mdb")

sSQL="SELECT tblLinks.GlossaryId, tblLinks.Link_e, tblLinks.Desc_e "
sSQL=sSQL & " FROM tblLinks"
sSQL=sSQL & " WHERE (((tblLinks.GlossaryId)="&theID&"))"


Set cnnGetRows = Server.CreateObject("ADODB.Connection")
cnnGetRows.Open conn

Set rstGetRows = cnnGetRows.Execute(sSQL)
arrLinks = rstGetRows.GetRows(, , Array("GlossaryId","Link_e","Desc_e"))

rstGetRows.Close
Set rstGetRows = Nothing
cnnGetRows.Close
Set cnnGetRows = Nothing

IF IsArray(arrLinks)THEN

Response.write ("<tr>"& vbCrLf)
Response.write ("<td width='15' background='../Images/2_0/equip_lines_left.jpg'></td>"& vbCrLf)
Response.write ("<td colspan='4' valign='top'>"&vbCrLf)
Response.write ("</BR>")
For Y = LBound(arrLinks, 2) To UBound(arrLinks, 2)
Response.write ("<A href='"&arrLinks(0,Y)&"' target='new'>"&arrLinks(1,Y)&"</A></BR>")
Next 'Y
Response.write ("</td>"& vbCrLf)
Response.write ("<td width='15' background='../Images/2_0/equip_lines_right.jpg'>&nbsp;</td>"& vbCrLf)
Response.write ("</tr>"& vbCrLf)
Else
'Exit Sub
END IF

'Erase arrLinks 'Clear the Array so that the contents don;t reappear in another RS

'<--------------------- END CHECK FOR LINKS ------------------------->
End Sub
%>

Spudhead
01-09-2007, 01:13 PM
I'm confused:



set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("../Access/Glossary.mdb")




Set cnnGetRows = Server.CreateObject("ADODB.Connection")
cnnGetRows.Open conn


I'm pretty sure that the ADODB.Connection object won't take an existing - and especially open - connection object as an Open() argument. You should just be able to reuse the connection:


Set rstGetRows = conn.Execute(strSQL)

Other than that... not sure. have you tried response.write() the uBounds of your array? If it's not getting populated right, that'll tell you.

tcadieux
01-09-2007, 03:30 PM
Quite right, did a little cleanup and it's all good now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum