none
Asynchronously retrieve data from database as soon as its retrieved. RRS feed

  • Question

  • Scenario:
    Bind the data(from db) to datagrid(windows form,UI) instantly, as soon as the records are fetched. kind of streaming

    Requirement:
    e.g: Query: select * from employee, would return 100,000 records. So as soon as the first record is fetched, grid should start binding showing the count of record being bound e.g: count:1, count:2.... and so on.

    Issue:
    I have tried exploring ADO.net feature like BeginExecuteReader kind of stuff, however, this is a means of fetching data asynchronously.
    e.g: if two grids were there, one to populate employee and other department.
    In the above case by the time employee data is being fetched, the process would not wait for it to be completed and would immediately fire the request for dept which is a different scene from the one mentioned above for my requirement.

    Questions:
    1) Can this be achieved.
    2) If answere to first is yes, then what is the way out/work around
    3) If possible, can some one share simple sample to show the same.

    Development Environment:
    VS2005
    MSSQL2008
    windows application , web service (smart client application)

    would be fine even if any one could give an example on windows only

    Any input will be greatly appreciated.


    Thanks & Regards Ajay Singh
    Tuesday, February 22, 2011 12:57 PM

All replies

  • Scenario:
    Bind the data(from db) to datagrid(windows form,UI) instantly, as soon as the records are fetched. kind of streaming

    Requirement:
    e.g: Query: select * from employee, would return 100,000 records. So as soon as the first record is fetched, grid should start binding showing the count of record being bound e.g: count:1, count:2.... and so on.

    Issue:
    I have tried exploring ADO.net feature like BeginExecuteReader kind of stuff, however, this is a means of fetching data asynchronously.
    e.g: if two grids were there, one to populate employee and other department.
    In the above case by the time employee data is being fetched, the process would not wait for it to be completed and would immediately fire the request for dept which is a different scene from the one mentioned above for my requirement.

    Questions:
    1) Can this be achieved.
    2) If answere to first is yes, then what is the way out/work around
    3) If possible, can some one share simple sample to show the same.

    Development Environment:
    VS2005
    MSSQL2008
    windows application , web service (smart client application)

    would be fine even if any one could give an example on windows only

    Any input will be greatly appreciated.


    Thanks & Regards Ajay Singh
    Tuesday, February 22, 2011 12:56 PM
  • I am not understanding the requirement you have.  With ADO.NET, you connect to the database, fill a DataAdapter's DataSet/DataTables, disconnect from the database.  The user/app should then do the data manipulation, then re-connect to the database, submit changes (dataAdapter.Update), then close the connection.

    So, in your scenario: you've got your 100k rows.  Now what?  Do you mean you want to query the db for any new rows since the last query returned rows? 


    James Crandall ~ http://javitechnologies.com Spatial Database Solutions
    Tuesday, February 22, 2011 6:52 PM
  • Hi James,

    Please accpet my apologies for a very late response.

    Here is the situation.

    The problem is, i am looking for fetching the rows from the database and populate it on the screen continously. Its like a data stream coming to the UI from the database, and the UI should not wait for the complete data to be fetched, and then bind it to the control (say Data grid or any third party tool e.g. Infragistrics:Ultragrid)

    eg: SQL Server 2008. When we query a large table or recordset, it continues to load the data on the screen, and shows the status as "Executing..." My requirement is the same, as my win application is about to fetch more than 2 million record on the screen and that is the requirement.

     


    Thanks & Regards Ajay Singh
    Friday, February 25, 2011 5:37 AM
  • Hi James,

    Have i been able to explain my scenario..??

    I would like to know if this is possible in the very first place, or is there a work around for the same.

     

     


    Thanks & Regards Ajay Singh
    Saturday, February 26, 2011 6:01 AM
  • Hello Ajay,

     

    Thanks for your post.

    According to your description, I think we could use the Stored Proc. Because in that way, we could retrieve data at the database client not in memory, so this will improve our performance.

    This thread would be helpful to you.

    http://stackoverflow.com/questions/71031/managing-large-volumes-of-data-stored-procedures-or-datasets-or-other

    If you have any questions please feel free to let me know.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 28, 2011 8:23 AM
    Moderator
  • Hi Jackie,

    Sorry for a late response. This is what i am looking for:

    Populate the data on the UI (windows application) as soon as the first record is fetched, method (web method/DAL method or whatever) should not wait for last record fetched or the connection to be closed and start returning the record to the callee.

    Till the first record is fetched, i contiue showing the progress bar.

    I am not really sure if this is possible. If yes then a sample would be great.

    If this is not possible as of now, is there a work around for the same. Can this be added in some future release as a part of ADO or something for developers like us can take advantage and make applications really interactive. (if i am making sense)

    Thanks in advance.


    Thanks & Regards Ajay Singh
    • Edited by AjSingh Monday, March 7, 2011 11:36 AM grammar
    Monday, March 7, 2011 11:34 AM
  • First question to comes to mind: Why would you ever need to display 100k records to a user? I think the reason there is no quick solution is because ADO.Net developpers answered that question when designing everything: there is no need.

    Tuesday, May 17, 2011 7:53 PM