How can I add to existing Record Set?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default How can I add to existing Record Set?

    I use code like this in order to create a recordset and enter data into the
    recordset:

    strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%red%';"
    set conn = Server.CreateObject("ADODB.Connection")
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &
    Server.MapPath("database.mdb")
    set recset = conn.execute (strSQL)
    response.write(recset("Item"))
    recset.movenext

    How can I do an additional query and add it to the existing recordset
    without removing the data from the first recordset. Maybe something like
    this?...

    strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%blue%';"
    set conn = Server.CreateObject("ADODB.Connection")
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &
    Server.MapPath("database.mdb")
    'I changed the line below as well as the first line
    set recset.AddToRecordset = conn.execute (strSQL)
    response.write(recset("Item"))
    recset.movenext

    I realize that I could change the first line to:
    strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%red%' AND Desc
    LIKE '%blue%';"

    .....but I would like to avoid that in order to avoid a bunch of re-coding of
    my site.

    Any ideas?


    michaaal Guest

  2. Similar Questions and Discussions

    1. Edit Existing Record
      Hi All My scenario is as follows: I have a page where users can edit existing records. Within this page I have several dropdownlists which is bound...
    2. Disabling a field when editing an existing record in a Datagrid
      I created an ASP.net form with an editable datagrid on it. I can create new records, and update and delete existing records. The problem I have is...
    3. Stop adding record in subform after record count = 1
      Can someone help in in what to put after the THEN statment to allow one entry if the Record count is =>1 in the Before insert or should I set the...
    4. Adding a new record when the record source is a query.
      Hello All, I have a form that runs a query. The reason it runs on a query is because prior to it opening I have a form from which you can pick...
    5. Update existing From record with changes on new To record
      I need to create a history record and update a current record from one input form. The two tables are joined with a query and the table names and...
  3. #2

    Default Re: How can I add to existing Record Set?

    michaaal wrote:
    > I use code like this in order to create a recordset and enter data
    > into the recordset:
    >
    > strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%red%';"
    > set conn = Server.CreateObject("ADODB.Connection")
    > conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &
    > Server.MapPath("database.mdb")
    > set recset = conn.execute (strSQL)
    > response.write(recset("Item"))
    > recset.movenext
    >
    > How can I do an additional query and add it to the existing recordset
    > without removing the data from the first recordset. Maybe something
    > like this?...
    >
    > strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%blue%';"
    > set conn = Server.CreateObject("ADODB.Connection")
    > conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &
    > Server.MapPath("database.mdb")
    > 'I changed the line below as well as the first line
    > set recset.AddToRecordset = conn.execute (strSQL)
    > response.write(recset("Item"))
    > recset.movenext
    It's not possible. Forget about this approach.
    >
    > I realize that I could change the first line to:
    > strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE '%red%' AND
    > Desc LIKE '%blue%';"
    You mean " ... OR Desc LIKE '%blue%'"

    >
    > ....but I would like to avoid that in order to avoid a bunch of
    > re-coding of my site.
    >
    > Any ideas?
    Several:
    1. Open a new recordset that uses both the old and new criteria.
    2. Use two recordsets
    3. Add the data from each new recordset to an array.


    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139