RecordSet without actual data behind it

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agoston Bejo

    RecordSet without actual data behind it

    I would like to use an ADODB.RecordSet object to temporarily store some data
    and then iterate through it. Actually it needs to be a RecordSet only
    because it is a perfect choice as data structure for what I want to do, I
    don't want to actually run queries or update tables with it.
    It seems to me, however, that the RecordSet works only if there's a query
    behind it. ADO complains about the RecordSet not being open when I try to
    add rows by the AddNew function, or try to add fields to it.

    Is there a way to use the RecordSet without actual database date behind it?
    Or is there maybe some object in VBScript that provides the same or at least
    similar functionality? (Apart from Scripting.Dicti onary, which is great, but
    I would like to use something more similar. :) )



  • Patrice

    #2
    Re: RecordSet without actual data behind it

    If I remember steps are :
    - create the recordset
    - append the fields
    - open the recordset
    - add data

    Seesing some code that repor the problme may help...

    Patrice

    --

    "Agoston Bejo" <gusz1@freemail .hu> a écrit dans le message de
    news:eepRTp4pEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
    > I would like to use an ADODB.RecordSet object to temporarily store some[/color]
    data[color=blue]
    > and then iterate through it. Actually it needs to be a RecordSet only
    > because it is a perfect choice as data structure for what I want to do, I
    > don't want to actually run queries or update tables with it.
    > It seems to me, however, that the RecordSet works only if there's a query
    > behind it. ADO complains about the RecordSet not being open when I try to
    > add rows by the AddNew function, or try to add fields to it.
    >
    > Is there a way to use the RecordSet without actual database date behind[/color]
    it?[color=blue]
    > Or is there maybe some object in VBScript that provides the same or at[/color]
    least[color=blue]
    > similar functionality? (Apart from Scripting.Dicti onary, which is great,[/color]
    but[color=blue]
    > I would like to use something more similar. :) )
    >
    >
    >[/color]


    Comment

    • Manohar Kamath [MVP]

      #3
      Re: RecordSet without actual data behind it

      This should answer your question:

      eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 


      --
      Manohar Kamath
      Editor, .netWire



      "Agoston Bejo" <gusz1@freemail .hu> wrote in message
      news:eepRTp4pEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
      > I would like to use an ADODB.RecordSet object to temporarily store some[/color]
      data[color=blue]
      > and then iterate through it. Actually it needs to be a RecordSet only
      > because it is a perfect choice as data structure for what I want to do, I
      > don't want to actually run queries or update tables with it.
      > It seems to me, however, that the RecordSet works only if there's a query
      > behind it. ADO complains about the RecordSet not being open when I try to
      > add rows by the AddNew function, or try to add fields to it.
      >
      > Is there a way to use the RecordSet without actual database date behind[/color]
      it?[color=blue]
      > Or is there maybe some object in VBScript that provides the same or at[/color]
      least[color=blue]
      > similar functionality? (Apart from Scripting.Dicti onary, which is great,[/color]
      but[color=blue]
      > I would like to use something more similar. :) )
      >
      >
      >[/color]


      Comment

      • Veign

        #4
        Re: RecordSet without actual data behind it

        You need to create a disconnected recordset.

        Basic structure of a disconnected recordset:

        '-------------------Start Code----------------------------
        'Create the Disconnected Recordset
        Dim RS As Recordset
        Set RS = New Recordset

        'Setup the Recordset
        With RS
        'Make sure there is no active connection
        .ActiveConnecti on = Nothing

        'Set for client side processing
        .CursorLocation = adUseClient

        'Single user updates
        .LockType = adLockBatchOpti mistic
        End With

        'Add Fields and Values to Recordset
        With RS.Fields
        .Append "ID", adBSTR
        .Append "Company", adBSTR
        .Append "Descriptio n", adBSTR
        End With

        'Open the Recordset
        RS.Open

        'Populate the Data in the Recordset
        With RS
        .AddNew
        .Fields("ID") = "ID123"
        .Fields("Compan y") = "Some Company"
        .Fields("Descri ption") = "Descriptio n"
        End With
        '-------------------------End Code---------------------------


        --
        Chris Hanscom
        MVP (Visual Basic)

        --

        "Agoston Bejo" <gusz1@freemail .hu> wrote in message
        news:eepRTp4pEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
        > I would like to use an ADODB.RecordSet object to temporarily store some[/color]
        data[color=blue]
        > and then iterate through it. Actually it needs to be a RecordSet only
        > because it is a perfect choice as data structure for what I want to do, I
        > don't want to actually run queries or update tables with it.
        > It seems to me, however, that the RecordSet works only if there's a query
        > behind it. ADO complains about the RecordSet not being open when I try to
        > add rows by the AddNew function, or try to add fields to it.
        >
        > Is there a way to use the RecordSet without actual database date behind[/color]
        it?[color=blue]
        > Or is there maybe some object in VBScript that provides the same or at[/color]
        least[color=blue]
        > similar functionality? (Apart from Scripting.Dicti onary, which is great,[/color]
        but[color=blue]
        > I would like to use something more similar. :) )
        >
        >
        >[/color]


        Comment

        • Bob Barrows [MVP]

          #5
          Re: RecordSet without actual data behind it

          Veign wrote:[color=blue]
          > You need to create a disconnected recordset.
          >[/color]

          Just a little nitpick:
          He actually needs to create an "ad hoc" recordset, not "disconnect ed", since
          "disconnect ed" implies that a previously connected recordset has been
          disconnected by setting the ActiveConnectio n property to Nothing. A
          disconnected recordset can be reconnected to the data source. An ad hoc
          recordset, since it never was connected to a data source, cannot be
          connected after it is open.

          Bob Barrows

          --
          Microsoft MVP - ASP/ASP.NET
          Please reply to the newsgroup. This email account is my spam trap so I
          don't check it very often. If you must reply off-line, then remove the
          "NO SPAM"


          Comment

          Working...