none
VB.NET: RecordSet or DataSet

    Question

  • Hi,

    Why is Recordset considered "Connected" and DataSet considered "Disconnected", what is the equivalent to RecordSet in VB.NET?

    • Moved by VMazurModerator Wednesday, January 27, 2010 11:11 AM (From:ADO.NET Data Providers)
    Thursday, July 19, 2007 6:16 AM

Answers

  • Hi,

     

    A recordset is considered connected because, depending on it's cursor type and other options, it remains connected to the source database as you use it. It has been a while but some options of a recordset allow it to retrieve records that are newly added to a table. For example, you create your recordset and read the first 10 records, during the read another user adds a record which just so happens to correspond to the 11 record on the recordset, the next read of the recordset on it's next read will return the newly added row. A dataset on the other hand would read all 10 records into memory, if another user writes a new row the dataset will never access this row because it isn't connected to the database.

     

    There is no real equivalent to the Recordset in VB.NET, some articles and people would suggest the DataReader class is close, and it sort of it is, but it has a major difference in that it's read only, forward only reader. It's not as flexible as the recordset as you can't write or update any data. You generally use the reader to populate a dataset or table, edit the details there, then use a data adapter or command objects to update the database again.

     

    Thursday, July 19, 2007 7:55 AM

All replies

  • Hi,

     

    A recordset is considered connected because, depending on it's cursor type and other options, it remains connected to the source database as you use it. It has been a while but some options of a recordset allow it to retrieve records that are newly added to a table. For example, you create your recordset and read the first 10 records, during the read another user adds a record which just so happens to correspond to the 11 record on the recordset, the next read of the recordset on it's next read will return the newly added row. A dataset on the other hand would read all 10 records into memory, if another user writes a new row the dataset will never access this row because it isn't connected to the database.

     

    There is no real equivalent to the Recordset in VB.NET, some articles and people would suggest the DataReader class is close, and it sort of it is, but it has a major difference in that it's read only, forward only reader. It's not as flexible as the recordset as you can't write or update any data. You generally use the reader to populate a dataset or table, edit the details there, then use a data adapter or command objects to update the database again.

     

    Thursday, July 19, 2007 7:55 AM
  • Recordsets can be "connected" or disconnected depending on how you define and use them.
    In MSF dev model, 3-tier apps are encouraged to use disconnected recordsets, connecting and then updating tables only when required.
    This allows tables to be accessed by more clients (think web apps) without maxing out on simultaneous connections and minimize on blocks or timeouts because one client have the db locked out.

    Datasets are considered "disconnected" because they are designed from ground up to behave much like disconnected recordsets with the adapter for updating.  This is because datasets are designed post-web era where 3-tier web apps are the norm.

    Recordsets were designed post client-server era and hence defaults to connected recordset but supports disconnected recordset for scalability.
    Wednesday, January 27, 2010 5:03 AM