Outputting Multiple Tables

Results 1 to 3 of 3

Thread: Outputting Multiple Tables

  1. #1
    Join Date
    Dec 1969

    Default Outputting Multiple Tables

    Hi, I'm trying to output multiple tables (from the same database) to an HTML page. Even though I close all the connections after the first table is complete, I get an error saying 'Name Redefined' when it comes to the second 'Dim objRS'. Any ideas?

  2. #2
    peterjl@austec.net.au Guest

    Default RE: Outputting Multiple Tables

    You cannot dim a variable twice in the same program scope. That is to say that if you are in the top level of your code, you can define a variable name only once. You can define the same name in any subroutine, but only once in each.<BR><BR>That said, once you have defined a variable, you can reuse that variable as often as you need. In other words, you can dim the variable, objRs at the start of your code, and then you can set it equal to a recordset based on one, use it to do whatever to the result, then close it. Then you can open it again based on a different query, read the records, and close it, and then you can do that as many times as you need.

  3. #3
    Join Date
    Dec 1969

    Default Yes, so the code would look like

    Dim objRS, objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "DSN=FooBar"<BR><BR>Dim strSQL1, strSQL2<BR>strSQL1 = "SELECT * FROM TABLE1" : strSQL2 = "SELECT * FROM TABLE2"<BR><BR>&#039;Open the Recordset object and displya the values from strSQL1<BR>objRS.Open strSQL, objConn<BR><BR>&#039;Display...<BR>&#039;...<BR><B R>&#039;Now, we want to populate objRS with strSQL2<BR>objRS.Close<BR>objRS.Open strSQL2, objConn<BR><BR>&#039;Display...<BR><BR>&#039;We&#0 39;re done, clean up<BR>objRS.Close<BR>Set objRS = Nothing<BR><BR>objConn.Close<BR>Set objConn = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts