1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Stored Queries

Discussion in 'C#' started by red_fiesta, Jan 12, 2007.

  1. #1
    I am running the following code to an access database

    
    ' Recordset Object
    Dim rs
    
    ' connecting to database
    con.Open connStr
    
    ' executing stored procedure
    Set rs = con.Execute ("exec SpotDesc")
    
    ' showing all records
    While Not rs.EOF
       Response.Write rs(0) & " " & rs(1) & "<br>"
    rs.MoveNext
    	
    Wend
    
    ' closing connection and freeing resources
    con.Close
    
    Set rs = Nothing
    
    Code (markup):
    This works and runs the stored procedure SpotDesc.

    One question I have is that this line brings back the results

    Response.Write rs(0) & " " & rs(1) & "<br>"

    but requires me to know how many colums are being returned, ie rs(0) is column 1 and rs(1) is column 2

    Is there a way of writing this line and it places all the columns there wheter it be 1, 2, or 3?
    SEMrush
    Ie a way of know how many columns are returned...


    Is there also a way to show the column heading?

    Thanks
     
    red_fiesta, Jan 12, 2007 IP
    SEMrush
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,607
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    you could run through a loop of the first record and detect if that object exits

    for x = 0 to ubound rs, detect if rs(x) is nothing.

    Their has to be a way in classic - I know it asp.net you can detect count of rows and columns so i bet if you dig deep enough, you shall find the count property :)
     
    ccoonen, Jan 12, 2007 IP
  3. kashem

    kashem Banned

    Messages:
    1,250
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi
    I guess there is a fields collection for recordset object, the fields should have a count propety.from that property i think you can find the no of columns it returning.
     
    kashem, Jan 13, 2007 IP