DataView vs DataReader

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mark (mark_at_Z-Zvolution.nZt)
Date: 09/09/04

  • Next message: bchandley: "Re: <customErrors mode="Off" />"
    Date: Fri, 10 Sep 2004 08:51:40 +1000
    
    

    Hi all, quick question [Please correct me where I am wong ;)], a DataView is
    memory resident "view" of data in a data table therefore once populated you
    can close the connection to the database. Garbage collection can then be
    used to "clean up" the DataView once it is not referenced and will not
    effect the number of connections to the database.

    A DataReader on the other hand always maintains a connection to the database
    and must be explicitly closed (Do not rely on garbage collection).

    Reason I am asking is that I have been give a heap of vb.net code and there
    are numerous functions that return a DataReader (Causing all sorts of SQL
    Timeout headaches, maximum connections reached etc). To solve this problem
    in the quickest amount of time I am thinking of replacing the DataReaders
    with DataViews so I can explicitly close the Database connection.

    Any other ideas (I would model the database via business objects and return
    these but I really do not have the time as we need a "quote" quick fix).

    Thanks
    Mark


  • Next message: bchandley: "Re: <customErrors mode="Off" />"

    Relevant Pages

    • Re: DataView vs DataReader
      ... Public Class getPerson ... ' Connect to database, ... Also, all the datareader objects, connection objects are ... Public Function GetPersonDetailsas DataView ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: DataView vs DataReader
      ... This is because the reader maintains an open ... connection to the database - a valuable resource. ... Now, a dataview, has nothing to do with database access itself. ... I definitely recommend you go ahead and eliminate the datareader. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: DataView vs DataReader
      ... Notice that it doesn't appear to close the datareader that is returned from ... the connection is closed because of the command behavior. ... Dim oPerson as new getPerson ... > Public Function GetPersonDetailsas DataView ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: DataView vs DataReader
      ... > Public Class getPerson ... Also, all the datareader objects, connection objects ... > Public Function GetPersonDetailsas DataView ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: DataView vs DataReader
      ... > Notice that it doesn't appear to close the datareader that is returned ... > the connection is closed because of the command behavior. ... >> Public Class getPerson ... >> Public Function GetPersonDetailsas DataView ...
      (microsoft.public.dotnet.framework.aspnet)