views:

598

answers:

1

My program that I am writing's purpose arose with this issue:

There are two users, each user saves to a .MDB file. One user has half the updated / correct information (the other half is outdated) and the other user has half the information (the other half is outdated).

User1: 25% + 25% = 50% current information needed the other 50% is outdated User1 works on 2 out of the 4 items.

User2: 25% + 25% = 50% current information needed the other 50% is outdated User2 works on 2 out of the 4 items.

I need to take that 50% (2 out of the 4 items) from lets say...User1 and add it to User2 making it 100% current (4 out of 4 items).

Their SQL style table structure is (should be anyways) identical (but if possible I would like to provide an event where for some a new table was added I would know)

If I could find out how to get all the table names from the DataTable, I could systematically array through the DataTable and replace the tables with the tables from the other .MDB file that I know need to be updated. I know DataSet has "DataSet.Tables" ...but that doesn't help me very much.

If I can do that, I can also add the tables to a combo box and create functionality to where whatever the combo box says, thats the table I will list on my Datagrid.

If any of you have any ideas on how to go about doing this (or if you even understand what i'm saying) please let me know. I'm 70% done with ths project, and these seem to be my last logic road blocks. I think I explained this right.

  1. How do I list just the Table names in a DataTable object.
  2. What are your ideas on taking specific Tables out of a .MDB file and adding them to another .MDB file?
  3. How would I go about inputting a ComboList drop-down box that included all the tables names...when I changed the table name it would list those contents on a Datagrid.
  4. Is there a way to list tables on a Datagrid, and when you click on a Table it lists the contents of that table (kind of like a Tree structure).

EDIT: I think he is right! I think DataTables are just one table whereas DataSets are sets of Tables. With that in mind, how do I list all the tables in a .MDB file into a DataSet? That would fix my problem perfectly.

+2  A: 

I thought that a DataTable object was only a single table and a DataSet was what contained one to many DataTables.

If you are looking for the actual name of your DataTable, that would be accessed through the DataTable.TableName property.

Edit: If you are wanting to add DataTables into a DataSet object, just create a new DataSet and then use the .Add() method.

Dim DS as new DataSet
Dim DT as new DataTable("TableName")

DS.Add(DT)

You should then be able to loop through your DataSet and retrieve table names by accessing each DataTable's TableName property:

For each table as DataTable in DS.Tables
    Console.Writeline(table.TableName)
Next
TheTXI
I think you are right! With that in mind... how do I add all my DataTables into a DataSet?
OneShot
I apologize if my code is in VB, it is the language I use all the time at work so every time I write code here I seem to forget and always do the VB version. If you just switch it up into C# syntax it should be fine.
TheTXI
So can I put all the tables in a .Txt...loop through them...add them to DataTable then add that to a DataSet? That will work, which is exciting, but I wish there was a way to do it dynamically! Haha, thats funny...VB syntax I didn't even realize it. C# > VB :)
OneShot