views:

47

answers:

2

I am trying to execute a query like "show tables". But I don't know the column names that will be returned by the query. I've tried using something like

RS.Fields(1).Name

to show me the names but that doesn't seem to work. Any suggestions? Here is the full code:

   Response.Buffer = true

    Dim oConn, oRs
    Dim qry, connectstr, i

    i = 1
    connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=xxx.xxx.xxx.xxx;DATABASE=;UID=;PWD="

    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open connectstr

    qry = "show tables"
    Set oRS = oConn.Execute(qry)

    while not oRS.EOF
        Response.Write("<td><b>" & oRS.Fields(i).Name  & "</b></td>")
        oRS.movenext
        i = i + 1
    wend


    Set oRs = nothing
    Set oConn = nothing
+2  A: 
For I=0 to oRS.Fields.Count - 1
   Response.Write("<td><b>" & oRS.Fields(I).Name  & "</b></td>")
Next
adatapost
+1. This should work.
David Stratton
+2  A: 

If you just want thie field names...

For Each fldF In objRec.Fields
 Response.Write fldF.Name
 Response.Write "<br />"
Next
David Stratton