Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2004
    Posts
    199

    Unanswered: dinamic table in memory via ADO or RDO?

    I can't remember is any way to create a dinamic table in memory via ADO or RDO?
    I mean a table or rowset object in memory that would be bound to datagrid control and updates in it afects to this dinamical table.
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  2. #2
    Join Date
    Jan 2004
    Posts
    184

    Re: dinamic table in memory via ADO or RDO?

    Do you mean a disconnected recordset?
    In abundance of water only the fool is thirsty. Bob Marley.

  3. #3
    Join Date
    Feb 2004
    Posts
    199
    I've read a topic years ago but can;t remember the way, If I can create disconected recordset without connecting to any DB source with fileds/types I need and be able to manipulate (add/edit/delete) as connected recordset, than it's what I need.
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  4. #4
    Join Date
    Feb 2004
    Posts
    199
    And, anyway i'm gonig to read help for details, but before I want to be shure, can I find a way to do what I need or there is no sence to search?
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  5. #5
    Join Date
    Jan 2004
    Posts
    184
    To create the disconnected recordset you need an initial connection, you retreive the data, and then close the connection. You can then do all you want to the recordset. When finished you reconnect to the database and save your changes.

    This control does all this automatically, all you need to do is set the Disconnected property to true. Take a look:
    In abundance of water only the fool is thirsty. Bob Marley.

  6. #6
    Join Date
    Feb 2004
    Posts
    37
    Its ADO, you can create a disconnected recordset, done it quite a few times - speed beats the crap out of large arrays, you do not need to initially connect to a database, you can create the recordset from scratch and then use it in the same way you would any other recordset including binding it to a control.

    quick sample of one way to do it:
    Const adVarChar = 200 'the SQL datatype is varchar

    'create a client side RS
    Set RSStatus = server.CreateObject("ADODB.RECORDSET")
    'Creates a column called status that is a VarChar and 25 long
    RSStatus.fields.append "ryg_status",adVarChar,25

    RSStatus.CursorLocation = adUseClient
    RSStatus.CursorType = adOpenStatic

    RsStatus.open
    RsStatus.addnew "ryg_status","Green"
    RsStatus.addnew "ryg_status","Yellow"
    RsStatus.addnew "ryg_status","Red"
    RSStatus.Update

    Brian.

  7. #7
    Join Date
    Feb 2004
    Posts
    199
    Thanks to all, here's a samle from MDAC SDK
    Code:
    dim r1 As ADODB.Recordset
    dim df As RDSServer.DataFactory
    
    Dim vntRecordShape(1)
       Dim vntField1Shape(3)
       Dim vntField2Shape(3)
    
       ' For each field, specify the name,
       ' type, size, and nullability.
    
       vntField1Shape(0) = "Name"   ' Column name.
       vntField1Shape(1) = CInt(129)   ' Column type.
       vntField1Shape(2) = CInt(40)   ' Column size.
       vntField1Shape(3) = False      ' Nullable?
    
       vntField2Shape(0) = "Age"
       vntField2Shape(1) = CInt(3)
       vntField2Shape(2) = CInt(-1)
       vntField2Shape(3) = True
    
       ' Put all fields into an array of arrays.
       vntRecordShape(0) = vntField1Shape
       vntRecordShape(1) = vntField2Shape
    
       Dim fields(1)
       fields(0) = vntField1Shape(0)
       fields(1) = vntField2Shape(0)
    
    Set df = New RDSServer.DataFactory
    Set r1 = df.CreateRecordSet(vntRecordShape)
    
       ' Populate the new recordset with data values.
       Dim fieldVals(1)
    
       ' Use AddNew to add the records.
       fieldVals(0) = "Joe"
       fieldVals(1) = 5
       r1.AddNew fields, fieldVals
    
       fieldVals(0) = "Mary"
       fieldVals(1) = 6
       r1.AddNew fields, fieldVals
    And it's works fine but, what I didn't get what I needed. I want to bind this recordset to Access form (via Recordset) actually code doesn't generates an error, but result is unexpecteble, rows are shown with no data and you can't edit data (regardless that r1 is updatable)
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  8. #8
    Join Date
    Feb 2004
    Posts
    37
    Ahh, datafactory, I new I was forgetting something.
    Where did you dim the the recordset and datafactory? Local or Module or Global level?
    I think after you have created the recordset, you may want to set/reset it to Keyset or Dynamic (whichever you need) and make sure your cursor is set to client (if it is set to server, you may get unpredictable problems, which don't necesarily show up as errors - although technically your PC will be the client and server in this case, I wouldn't trust that to Microsoft).

    Brian.

  9. #9
    Join Date
    Feb 2004
    Posts
    199
    "Where did you dim the the recordset and datafactory? Local or Module or Global level?"

    I've tryied both way, anyway, r1 & df are alive while code is runing.


    "I think after you have created the recordset, you may want to set/reset it to Keyset or Dynamic (whichever you need) and make sure your cursor is set to client "

    Acctually maybe that is the problem but how can I manipulate with this proerties when recordset is already open? If I had a connection I could open recordset via Open method with options I need, but does DataFactory provide connetion object?
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  10. #10
    Join Date
    Feb 2004
    Posts
    199
    MDAC Help

    "The CursorType property is read/write when the Recordset is closed and read-only when it is open."

    CursorLocation
    "This property is read/write on a Connection or a closed Recordset, and read-only on an open Recordset."
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

Posting Permissions

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