Re: Of Java and C#




"LX-i" <lxi0007@xxxxxxxxxxxx> wrote in message
news:d182b$45bea73f$454920f8$8426@xxxxxxxxxxxxxx
andrewmcdonagh wrote:
Doh...oh yes re-reading your post I see that now... Saw the talk about
Java and missed the c# connection to the class.

Not to worry though...whilst I don't know the full c# library yet I do
know OO and c#'s approaches so if you want....

Well, I forgot to e-mail the source to myself... :( But in the mean
time, I have a question for you seasoned OO folks...

Say, for example, that there is a library application where there is a
"book" object with a method of checkMeOut(), that takes a patron object,
and modifies it to indicate that it is now checked out by the given
patron.

Assuming that this is a persistent application, at what point is the
information stored off? Does checkMeOut() do the work of updating the
database *and* updating the object in memory, or should there be a
separate commitChanges() method that would update a data store with the
information contained in the current instance of that object?


The modern approach to this is to use a data adapter and a Dataset that are
"disconnected" (updated offline). The DB Connection is used to run the
query, then dropped. Subsequent processing is against the Dataset
(previously a "result set"). Changes to the dataset can be committed any
time you want, and the connection is re-established automatically.
Synchronization and detection of changes that may have occurred while you
were offline, are all handled by the data adapter, which provides methods
and properties to let you do whatever you want. Here's a link that may help:
http://www.codersource.net/csharp_adonet_tutorial_ed.html

See also the C# "Dataset.AcceptChanges()" method and the
"DataAdapter.Update()" methods. This is very powerful stuff and I am still
getting my head round it. :-) Fortunately, it works as documented...

Your checkMeOut() method could update the Dataset and/or commit the changes,
depending on what you want/need.

(Personally, I'd put the DB stuff into another Class/Method and invoke it
from checkMeOut())

Pete.


.



Relevant Pages

  • Re: Multi-threaded apps and data readers
    ... So if I kept the connection open all ... commands reader, how would I prevent the readers from clashing or do they ... cmd.CommandText = "SELECT AccountName, accountid from accounts" ... I know it is possible because the data adapter class ...
    (microsoft.public.dotnet.framework.adonet)
  • Cannot access Access database
    ... I am a new user developing a Web form in vsnet. ... connection, a data adapter and a data set. ... When I ask to preview the data from the data adapter properties box I ...
    (microsoft.public.vsnet.general)
  • Accessing Paradox Tables From C# Using ODBC
    ... I have added a Data Connection to the Paradox table in the Server ... I have also generated a data set from the data adapter. ...
    (microsoft.public.dotnet.general)
  • Re: How to use ADO.NET to run a data set returned stored procedure ?
    ... You can use the same command object to create a data adapter. ... The data adapter will open and close the connection for you so you ... query in difference function by declaire the variable in global, ...
    (microsoft.public.dotnet.languages.vb)