Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2007, 04:06 PM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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("&nbsp;")
                      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>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Write doesn't work? Ron Howerton Pro JSP 1 March 27th, 2007 02:03 AM
Response.Write won't work? Ron Howerton JSP Basics 1 March 23rd, 2007 07:39 AM
response.write crmpicco Classic ASP Basics 1 January 27th, 2005 06:31 PM
response.write netcrawler Classic ASP Databases 4 September 29th, 2004 10:13 AM
Response.write Sach Classic ASP Components 5 March 19th, 2004 06:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.