Professional Web Applications Themes

How can I add to existing Record Set? - ASP Database

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 ...

  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. #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

Similar Threads

  1. Edit Existing Record
    By vdykcj in forum Dreamweaver AppDev
    Replies: 2
    Last Post: March 31st, 03:28 PM
  2. Replies: 1
    Last Post: October 3rd, 04:20 PM
  3. Disabling a field when editing an existing record in a Datagrid
    By Mark Perona in forum ASP.NET General
    Replies: 2
    Last Post: August 12th, 07:24 PM
  4. Stop adding record in subform after record count = 1
    By Charlie in forum Microsoft Access
    Replies: 0
    Last Post: July 31st, 10:42 AM
  5. Replies: 0
    Last Post: July 28th, 05:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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