ASP classic db question

asp-classicdatabase

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

Best Answer

For I=0 to oRS.Fields.Count - 1
   Response.Write("<td><b>" & oRS.Fields(I).Name  & "</b></td>")
Next
Related Topic