Re: Collections to Database

From: Val Mazur (group51a_at_hotmail.com)
Date: 06/24/04


Date: Wed, 23 Jun 2004 22:03:06 -0400

Hi,

Any reason to load data into collection? It looks like you are trying to do
the job which already done and optimized in ADO.NET. I would suggest to lad
data into the DataSet, rather than into collection and set the relations
between the DataTables inside of the DataSet. In this case you will avoid
additional steps to load data from the collection and code would look much
simpler. After changes completed in a dataset, you could use DataAdapter to
update actual database

-- 
Val Mazur
Microsoft MVP
"Jac" <Jac@discussions.microsoft.com> wrote in message 
news:8482E086-B7B1-4977-874D-70CFCE9A8A0E@microsoft.com...
> Hey,
> Newbie in using ADO.NET.
>
> What I do now : I read the database with an OleDbDataReader. For each row 
> I read I make an object (let say Person + that object contains a 
> collection with the addresses etc.). All the objects I put in a collection 
> called 'Persons'.
> Then I work on that collection (delete, update, add). Each object in the 
> collection contains a state (Add, Update or deleted state).
>
> At the end I want to go back to the database.
> What is a best practice to do this?
> - Do I pump my collection 'Persons' in a dataset, and for each row I set 
> the datarowstate (= state of each object in my collection). I don't know 
> if this is possible. And then I do dataset.Update and 
> Dataset.Acceptchanges?? Is that not too much (collection to dataset, 
> dataset to database)??
> - I cannot use the SQLCommandBuilder because I need joins. What do I have 
> to use if I will update the database???
>
>
> Thanks in advance.
> 


Relevant Pages

  • Re: Limit in Dataset?
    ... > "Val Mazur" wrote in message ... >> idea to load dataset with the whole table from the database, ... >> case you need to load data from the XML file, ... >> database and you will be able to load big dataset. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Limit in Dataset?
    ... to load dataset with the whole table from the database, ... you need to load data from the XML file, ... Val Mazur ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Design help
    ... Have a look at Parent configurations, ... need to load data from all 5 database into one staging database table. ... I have created one ssis package that load data from one database, ...
    (microsoft.public.sqlserver.dts)
  • Re: Automatically populating a dataset with all the mdbs tables
    ... But what is the reason to do this. ... Val Mazur ... "Phil Greg" wrote in message ... > database I'm accessing, and create the tables I need one by one, as well ...
    (microsoft.public.dotnet.framework.adonet)
  • MS Access Database - Chinese Characters
    ... When we load data from Excel using a MS Access 2000 database and it is open ... No Chinese characters. ...
    (microsoft.public.access.queries)