marko_one
03-27-2003, 06:04 PM
Hi All,
I am having a problem with an array and using it more than once through a loop. If I run it so that I response.end after the first operation it runs and sisplays the results from the database no problem, as soon as I take out the response.end I get the error as shown in the subject.
I realizethe code below is badly formed, originally I written it properly, but had to alter it bit by bit to see if i could fix the errors, but I am now sick to death of it and need someone to help me because I dont understand why it will run once ok but no more.
Thanks in advance
<%
'Databse Driver
dbDriver = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
'path to the databases
dbPath = server.mappath("db") & "\"
strConn = dbDriver & dbPath & "Total.mdb"
sql = "SELECT * From apptData;"
dim oConn
dim oRS
set oConn = server.createobject("ADODB.Connection")
set oRS = server.createobject("ADODB.Recordset")
oConn.Open strConn '
oRS.Open sql, oConn
%>
<table border="1", cellpadding="5">
<tr bgcolor="skyblue">
<th>Address</th>
</tr>
<%
Dim dtaAddress
Dim strAddress
Dim add1
Dim add2
Dim add3
Dim add4
Dim add5
Dim i
i = 0
While Not oRS.EOF
%>
<tr>
<%
strAddress = split(Trim(oRS("Address")), "#")
add1 = strAddress(0)
add2 = strAddress(1)
add3 = strAddress(2)
add4 = strAddress(3)
add5 = strAddress(4)
'Tried erase and just plain leaving the array
Redim strAddress(5)
'Response.Write(add1 & "<BR>")
'Response.Write(add2 & "<BR>")
'Response.Write(add3 & "<BR>")
'Response.Write(add4 & "<BR>")
'Response.Write(add5 & "<BR>")
'Response.End
dtaAddress = ""
if add1 <> "" Then
dtaAddress = dtaAddress & add1 & "<br>"
End If
if add2 <> "" Then
dtaAddress = dtaAddress & add2 & "<br>"
End If
If add3 <> "" Then
dtaAddress = dtaAddress & add3 & "<br>"
End If
if add4 <> "" Then
dtaAddress = dtaAddress & add4 & "<br>"
End If
If add5 <> "" Then
dtaAddress = dtaAddress & add5
End If
'response.Write(dtaAddress & "#")
'response.end
%>
<td><%=dtaAddress%> </td>
</tr>
<%
'response.end
oRS.MoveNext
i = i + 1
'response.end
Wend
%>
</table>
<%
oRS.Close
set oRS=nothing
oConn.close
set oConn=nothing
%>
I am having a problem with an array and using it more than once through a loop. If I run it so that I response.end after the first operation it runs and sisplays the results from the database no problem, as soon as I take out the response.end I get the error as shown in the subject.
I realizethe code below is badly formed, originally I written it properly, but had to alter it bit by bit to see if i could fix the errors, but I am now sick to death of it and need someone to help me because I dont understand why it will run once ok but no more.
Thanks in advance
<%
'Databse Driver
dbDriver = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
'path to the databases
dbPath = server.mappath("db") & "\"
strConn = dbDriver & dbPath & "Total.mdb"
sql = "SELECT * From apptData;"
dim oConn
dim oRS
set oConn = server.createobject("ADODB.Connection")
set oRS = server.createobject("ADODB.Recordset")
oConn.Open strConn '
oRS.Open sql, oConn
%>
<table border="1", cellpadding="5">
<tr bgcolor="skyblue">
<th>Address</th>
</tr>
<%
Dim dtaAddress
Dim strAddress
Dim add1
Dim add2
Dim add3
Dim add4
Dim add5
Dim i
i = 0
While Not oRS.EOF
%>
<tr>
<%
strAddress = split(Trim(oRS("Address")), "#")
add1 = strAddress(0)
add2 = strAddress(1)
add3 = strAddress(2)
add4 = strAddress(3)
add5 = strAddress(4)
'Tried erase and just plain leaving the array
Redim strAddress(5)
'Response.Write(add1 & "<BR>")
'Response.Write(add2 & "<BR>")
'Response.Write(add3 & "<BR>")
'Response.Write(add4 & "<BR>")
'Response.Write(add5 & "<BR>")
'Response.End
dtaAddress = ""
if add1 <> "" Then
dtaAddress = dtaAddress & add1 & "<br>"
End If
if add2 <> "" Then
dtaAddress = dtaAddress & add2 & "<br>"
End If
If add3 <> "" Then
dtaAddress = dtaAddress & add3 & "<br>"
End If
if add4 <> "" Then
dtaAddress = dtaAddress & add4 & "<br>"
End If
If add5 <> "" Then
dtaAddress = dtaAddress & add5
End If
'response.Write(dtaAddress & "#")
'response.end
%>
<td><%=dtaAddress%> </td>
</tr>
<%
'response.end
oRS.MoveNext
i = i + 1
'response.end
Wend
%>
</table>
<%
oRS.Close
set oRS=nothing
oConn.close
set oConn=nothing
%>