Response.Write an Array (OK in Access but Not in M
Hi,
I have been trying to get the following working for days - I wonder if anyone could help me?
I am trying to list a set of database entries as a newspaper column. I am using classic ASP (not NET). It would seem that things fail when the code gets to
Code: ( text )
if DataArray(i,j) <> "" then
The following code has been working great when connected to an Access database. I wish to swop the database to MySQL. I have proven that I am connecting OK but it will simply not write out the results when using a MySQL DB.
Any help or clues would be gratefully received!
Thanks.
<%
dim ColumnArray(), DataArray()
dim intColumns, sql, i, j, k, txtContinue
dim rs, Conn, main
intColumns = 4
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=204.14.108.61;DATABASE=xxxxxx; USER=xxxxxx;PASSWORD=xxxxxx;OPTION=4;"
Conn.Open
main=request.querystring("IN")
sql = "SELECT DISTINCT towns FROM towns WHERE towns LIKE '" & main & "%' ORDER BY towns ASC"
set rs = server.CreateObject("ADODB.Recordset")
rs.Open sql, Conn, adOpenStatic
redim ColumnArray(intColumns-1)
for i = 0 to ubound(ColumnArray)
ColumnArray(i) = rs.RecordCount * (i+1)/(intColumns)
next
if intColumns > 1 then
redim DataArray(rs.RecordCount/(intColumns-1),intColumns)
else
redim DataArray(rs.RecordCount,intColumns)
end if
for i = 0 to intColumns - 1
k = 0
do while j < ColumnArray(i)
DataArray(k,i) = rs("towns")
j = j + 1
k = k + 1
rs.MoveNext
loop
next
%>
<table border="0" width="100%" align="center">
<p><%
for i = 0 to ubound(DataArray)
Response.Write("<tr>")
for j = 0 to intColumns - 1
Response.Write("<td>")
if DataArray(i,j) <> "" then
'Response.Write(DataArray(i,j))
%><a href="instructorsTest.asp?IN=<%Response.Write(Data Array(i,j))%>"><%Response.Write(DataArray(i,j))%></a><%
else
Response.Write(" ")
end if
Response.Write(" </td>")
next
Response.Write("</tr>")
txtContinue = ""
for j = 0 to intColumns - 1
txtContinue = txtContinue & DataArray(i+1,j)
next
if txtContinue = "" then Exit For end if
next
rs.Close
set rs = Nothing
conn.Close
set conn = Nothing
%> </p>
</table>
|