Results 1 to 9 of 9

Thread: Create Blank Recordset

  1. #1

    Thread Starter
    Member Manor39's Avatar
    Join Date
    Mar 2002
    Location
    Cambridgeshire
    Posts
    38

    Create Blank Recordset

    As you'll guess from this posting I'm very new to Recordsets.

    My question is, how do you create a blank recordset with just column headers?

    I've created the one recordset from the database, but I now need to trawl through it and sort it into a very specific order (which is not possible by query) and I thought I would add each row to a new recordset, so that this one ends up in the correct order.

    Regards
    John
    Last edited by Manor39; Jul 2nd, 2002 at 05:29 AM.
    Regards
    John Pike

    There are never any problems, just challenges.

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    I guess you could always use an improbable criterion in your SQL statement:

    e.g.
    [ADO]
    rs.Open ("select * from myTable where Customer = 'abcdefghi'"), myConnection

    (assuming you have no customers called abcdefghi)

    There doesn't seem to be any specific methods to do it.... (aside form constructin a fresh recordset from scratch - which to me is a waste of time and effort...)

  3. #3

    Thread Starter
    Member Manor39's Avatar
    Join Date
    Mar 2002
    Location
    Cambridgeshire
    Posts
    38
    I forgot to mention in my previous posting that it will end up as an excel spreadsheet. My plan was to sort the recordset and then dump the lot in one go to the spreadsheet, but I think I will have post each row as I'm sorting.

    Regards
    John.
    Regards
    John Pike

    There are never any problems, just challenges.

  4. #4
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Code:
     SELECT * FROM YourTable WHERE 1 = 2
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  5. #5
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Originally posted by Manor39
    I forgot to mention in my previous posting that it will end up as an excel spreadsheet. My plan was to sort the recordset and then dump the lot in one go to the spreadsheet, but I think I will have post each row as I'm sorting.

    Regards
    John.
    There's nothing wrong with putting each line into the spreadsheet as long as you keep an instance of the spreadsheet open throughout - it may save you from having to construct complicated recordsets....

    If you need help in this, just ask

  6. #6
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Oh yeah, Gary's example is nice too

    (his code, not his avatar )

  7. #7
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Originally posted by Gaffer
    Oh yeah, Gary's example is nice too

    (his code, not his avatar )

    I took me 3 hours to decide on that
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  8. #8
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Originally posted by Gary.Lowe



    I took me 3 hours to decide on that
    dammit you changed it!!!!!! (thought you were still mr Vegas.... )

  9. #9

    Thread Starter
    Member Manor39's Avatar
    Join Date
    Mar 2002
    Location
    Cambridgeshire
    Posts
    38
    This works:

    VB Code:
    1. rs.Fields.Append "NewField", adVarChar, 50, adFldKeyColumn
    2. rs.Open

    Thanks for your help guys.
    Regards
    John Pike

    There are never any problems, just challenges.

Posting Permissions

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



Click Here to Expand Forum to Full Width