.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Best way to implement a database class? (newbie question, please point me in the right direction)
 

Best way to implement a database class? (newbie question, please point me in the right direction)

I'm somewhat new to .NET and I'm looking for some advice on how to implement a simple database class. I've read all the documentation about DataAdapters, DataReaders, DataTables, and DataSets, but I'm a little confused on what's the best way (eg: easiest) to do this.

Let's say I have a simple table called customers and each customer has several orders.

How can I make a class called CustomerDatabase where I can easily have functions like this:

CustomerDatabase.GetRecentOrder(); // Returns an Order structure that I can modify and then call Update() on?
CustomerDatabase.GetAllOrders(); // Returns a List of orders
CustomerDatabase.Customers(0).Order(10).Description = "New pair of shoes"; // eg. update an existing order extremely easy
etc, etc.

I think I need to fool around with a DataAdapter and DataSet but I'm a little lost...

Can somebody point me in the right direction?
sofakng

I am a relative beginner too, but I hope I can help a bit.

Have you seen Recommendations for Data Access Strategies? It makes clear thatDataTables and DataSets are in-memory copies of data. It helps to understand that.

Something else that would help is to define your requirements. You need to first decide what needs to be done. That will influence the solution. In other words, to use the terminology in the above article, your requirements can determine whether it is best to "store data in a dataset" or "perform operations directly against the database". Withoutknowing your requirements, no one can provide significant guidance with descisions such as that.


Sam Hobbs; see my SimpleSamples.Info
Simple Samples
Hi sofakng,

Maybe you can start learning about the strong typed datasets.

Regards,
Louk
Loukoum

I am a relative beginner too, but I hope I can help a bit.

Have you seen Recommendations for Data Access Strategies? It makes clear thatDataTables and DataSets are in-memory copies of data. It helps to understand that.

Something else that would help is to define your requirements. You need to first decide what needs to be done. That will influence the solution. In other words, to use the terminology in the above article, your requirements can determine whether it is best to "store data in a dataset" or "perform operations directly against the database". Withoutknowing your requirements, no one can provide significant guidance with descisions such as that.


Sam Hobbs; see my SimpleSamples.Info
Simple Samples

You can use google to search for other answers

Custom Search

More Threads

• .NET Framework Access to Remote File Share
• GDI+ Generic Error Saving Tiff Page
• Where is the .NET 2.0 Beta 2 redistributable located?
• How ToString method is overridden by System.Object type?
• Local variables self dispose?
• Tracing the VS add-in
• Settings File Across a solution
• Delegate.Remove takes lot of time.
• Any way to get the X509 Certificate PrivateKey as text?
• Interrupting sleeping threads