get data from database into arraylist. RRS feed

  • Question

  • Hi all,
    I'm using visual c# Orcas(not express version) and i want to know how
    to access the data from my database and store it into an arraylist or in string form so i can manipulate it and store it again into the database later on.
    Any help would be appreciated, thanks.
    Monday, July 23, 2007 12:32 AM



    The problem you have posed is a very general one, so it would be helpful to know more about what exactly you are trying to accomplish (like what database server you are working against), what you would like to do with the data once you retrieve it, what technologies you have considered, etc. 


    For example, one approach would be to use the DataSet as the in-memory data structure and change tracking mechanism, and a data adapter to transfer data between the DataSet and your database.  This would be the normal approach in ADO.Net 2.0, and Visual Studio includes wizards which can help put together this kind of solution.


    On the other hand, you might consider something more like LINQ to Entities or LINQ to SQL which will help to transfer data from the database into a list of in-memory objects where you can have more direct control over the object definitions, each of these technologies would allow you to make changes to the objects, track those changes and then push the changes back to the database, but you would take a fairly different approach to get your solution started with one of these, and of course they have different performance and other characteristics than a DataSet solution.


    Yet another possibility is that you could write more of this code by hand and directly access data from a DataReader and then create your own SQL update statements.  This would require more hand-coding but might provide better scalability for certain kinds of solutions.


    It all depends more on what exactly you are trying to accomplish.  I recommend that you give some thought to more details of what you are doing, and then spend some time looking into online tutorials on the various technologies in order to see which one is the best fit for you.  After that if you have a question about some detail of one of using one of these technologies, don't hesitate to post back that question--the more specific the question and the more targeted your choice of which forum to post to, the more likely you will get a quick response.


    Good luck!

    - Danny

    Sunday, July 29, 2007 3:55 AM