|
 |
asp_databases thread: Need help with multiple recordsets
Message #1 by chrscote@9... on Mon, 21 Oct 2002 01:10:53
|
|
I am having a few problems with displaying some data from my database. I
have 2 separate sections in one page which display data from 2 different
tables. I have tried setting up 2 recordsets, one for each query I need
to retrieve. However, after getting the data from the first table fine, I
always get an error saying "Object does not support this property or
method: 'Open'" I have listed below the code I am using for this page. I
hope someone can find what I'm doing wrong, 'cause I can't seem to find it.
<% dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=Baseball"
SQLStr = "SELECT * FROM BattersTotals;"
dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.open SQLStr, conn
dim AB, Hits, Dbl, Triple, HR, Walk, HP, avg, slg, obp
Do while not objRS.EOF
AB = objRS("AB")
Hits = objRS("H")
Dbl = objRS("2B")
Triple = objRS("3B")
HR = objRS("HR")
Walk = objRS("BB")
HP = objRS("HP")
if (AB > 0) Then
avg = FormatNumber(Round(Hits/AB,3),3)
slg = FormatNumber(Round(((4*HR) + (3*Triple) + (2*Dbl) +
(Hits - (Dbl+Triple+HR)))/AB,3),3)
obp = FormatNumber(Round((Hits + Walk + HP) / AB,3),3)
else
avg = "0.00"
slg = "0.00"
obp = "0.00"
end if
%>
<tr>
<td><%=objRS("H")%></td><td>......</td>
</tr>
<% objRS.moveNext
Loop
objRS.close
set objRS = nothing
objRS2 = Server.CreateObject("ADODB.Recordset")
SQLStr = "SELECT * FROM PitchersTotals;"
objRS2.open SQLStr, conn //Error occurs here
Do while not objRS2.EOF
...
...
...
objRS2.moveNext
Loop
objRS2.close
set objRS2 = nothing
%>
Thank you in advance for your help.
Chris
</tr>
Message #2 by "Drew, Ron" <RDrew@B...> on Mon, 21 Oct 2002 07:47:00 -0400
|
|
You may want to try
Set SQLStr =3D nothing along with objRS
or just use SQLStr2
-----Original Message-----
From: chrscote@9... [mailto:chrscote@9...]
Sent: Sunday, October 20, 2002 9:11 PM
To: ASP Databases
Subject: [asp_databases] Need help with multiple recordsets
I am having a few problems with displaying some data from my database.
I
have 2 separate sections in one page which display data from 2 different
tables. I have tried setting up 2 recordsets, one for each query I need
to retrieve. However, after getting the data from the first table fine,
I
always get an error saying "Object does not support this property or
method: 'Open'" I have listed below the code I am using for this page.
I
hope someone can find what I'm doing wrong, 'cause I can't seem to find
it.
<% dim conn
set conn =3D Server.CreateObject("ADODB.Connection")
conn.Open "DSN=3DBaseball"
SQLStr =3D "SELECT * FROM BattersTotals;"
dim objRS
set objRS =3D Server.CreateObject("ADODB.Recordset")
objRS.open SQLStr, conn
dim AB, Hits, Dbl, Triple, HR, Walk, HP, avg, slg, obp
Do while not objRS.EOF
AB =3D objRS("AB")
Hits =3D objRS("H")
Dbl =3D objRS("2B")
Triple =3D objRS("3B")
HR =3D objRS("HR")
Walk =3D objRS("BB")
HP =3D objRS("HP")
=09
if (AB > 0) Then
avg =3D FormatNumber(Round(Hits/AB,3),3)
slg =3D FormatNumber(Round(((4*HR) + (3*Triple) + (2*Dbl)
+
(Hits - (Dbl+Triple+HR)))/AB,3),3)
obp =3D FormatNumber(Round((Hits + Walk + HP) / AB,3),3)
else
avg =3D "0.00"
slg =3D "0.00"
obp =3D "0.00"
end if
%>
<tr>
<td><%=3DobjRS("H")%></td><td>......</td>
</tr>
<% objRS.moveNext
Loop
objRS.close
set objRS =3D nothing
objRS2 =3D Server.CreateObject("ADODB.Recordset")
SQLStr =3D "SELECT * FROM PitchersTotals;"
objRS2.open SQLStr, conn //Error occurs here
Do while not objRS2.EOF
...
...
...
objRS2.moveNext
Loop
objRS2.close
set objRS2 =3D nothing
%>
Thank you in advance for your help.
Chris
</tr>
|
|
 |