4 messages in com.mysql.lists.dotnetRE: Accessing Multiple Tables| From | Sent On | Attachments |
|---|---|---|
| Brian McWilliams | 03 Nov 2005 17:41 | |
| Brandon Schenz | 03 Nov 2005 19:17 | |
| Brian McWilliams | 03 Nov 2005 20:20 | |
| Blue Wave Software | 06 Nov 2005 04:15 |
| Subject: | RE: Accessing Multiple Tables![]() |
|---|---|
| From: | Blue Wave Software (mys...@bluewavesoftware.com.au) |
| Date: | 11/06/2005 04:15:08 AM |
| List: | com.mysql.lists.dotnet |
As anyone who has been programming with ADO and ADO.Net know there are pros and cons at each approach. If you are programming a client programming and wanting to minimize memory used creating individual data adapters and commands can become resource hungry.
On my large scale projects where resources are critical I have my own data object that is simply a data connection, a data command and a data reader. In the larger projects I actually use double that. One set for reading from a data base on a server and the second one for writing to a database. Helps balance load.
Because my app work with a large number of tables at a time but only a very few rows at a time I create a data access layer with two functions. Get Data and update Data. Get data simply creates and reads data into a data table to be appended to a dataset. The update data function simply goes through the records of a data table passed to it and if it is new creates and executes an insert command, if changed creates and executes an update command and if delete deletes the record. I find this work extremely efficiently. Updating 12 tables with over 1000 fields in total in well under a second.
I was originally forced to use this method because of my complex update and insert commands which left me with two options. Create code to create each data adapter manually and create commands and parameters, create a stored procedure which is great for My Sql but could cause problems if I wished to use other database formats in the feature. Creating the commands initially was a pain but it allows for flexibility.
To ensure continuity between when the data was read from the table and the data being updated all tables in the database have an updated field which is a simple time stamp. The execution of each command has a where cause of " where id = '123' and updated = '2006-1-1 11:11:11' if the current tables updated field doesn't match the updated field then the command is not performed. To simplify the end result is that if the data read originally is not the same then the table isn't updated and the end user is alerted to this fact. I also prefer this method in my commercial programs as I have more control to the program flow and when you need to trap for the most computer illiterate person possible this is a grate benefit.
What you do for each project is up to what the project. For a commercial product resources will need to be taken into account and the method I use only keeps the currently required data in memory and just a data connection, data command and data reader and that all. IF you just want rapid development and the hardware is a know entity where resources arent an issue then creating individually data adapters, commands for each one is the way to go.
Regards, Justin Elward
Blue Wave Software Pty Limited jus...@bluewavesoftware.com.au
----------------------------------------------------------------------------
------------------- DISCLAIMER: This message is proprietary to Blue Wave Software Pty Limited (BWS) and is intended solely for the use of the individual or individuals to whom it is addressed. It may contain privileged or confidential information and should not be circulated with out informing BWS prior or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly prohibited from using, copying, altering, or disclosing the contents of this message. BWS accepts no responsibility (except where required under Australian law) for loss or damage arising from the use or misuse of the information transmitted by this email including damage from virus."
----------------------------------------------------------------------------
-------------------
-----Original Message----- From: Brian McWilliams [mailto:emcw...@msn.com] Sent: Friday, 4 November 2005 12:42 PM To: dot...@lists.mysql.com Subject: Accessing Multiple Tables
Hello all. I have a few questions for those of you out there more experienced with MySQL application design.
My application makes use of a great deal of tables (10 currently, more to come). What is the best way to be able to retrieve these tables? I have tried to do joins before, but have found that I can not update the data after a join has been performed.
Second: Currently with my application, I have declared a single MySQLConnection, and a unique MySQLAdapter, MySQLCommand, and MySQLCommandBuilder for each of the tables that are being retrieved now (they are each being retrieved individually). Is this the correct approach to take or are there better methods?
Thanks, Brian McWilliams emcwill792 <at> msn.com
_________________________________________________________________ Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/
-- MySQL on .NET Mailing List For list archives: http://lists.mysql.com/dotnet To unsubscribe: http://lists.mysql.com/dotnet?unsub=mys...@bluewavesoftware.com.au




