.TableName, why use that?
-
Hi all, I've been trying to determine a good reason why one would use .TableName when the name of the DataTable variable is required anyway and .TableName is optional. Seems that having spent 10 minutes googling, gave me good enough reason to post here what seems like should be an easy question to answer...... I'm assuming it is the same type of situation one would encounter using ProEngineer (CAD). One could name a part with its part name (which would be the file name) and also have an optional "common name". So you could have 012569.prt which has a common name of Bolt. However, in my opinion, have different nomenclature for the same item is usually a "state of confusion" waiting to happen. Thanks!
-
Hi all, I've been trying to determine a good reason why one would use .TableName when the name of the DataTable variable is required anyway and .TableName is optional. Seems that having spent 10 minutes googling, gave me good enough reason to post here what seems like should be an easy question to answer...... I'm assuming it is the same type of situation one would encounter using ProEngineer (CAD). One could name a part with its part name (which would be the file name) and also have an optional "common name". So you could have 012569.prt which has a common name of Bolt. However, in my opinion, have different nomenclature for the same item is usually a "state of confusion" waiting to happen. Thanks!
Remember that a DataTable was originally introduced as part of a DataSet, which allows a hierarchical linkage of tables (or you could just bundle several tables together in one if you liked). The TableName allows you to do things like search for the table in the DataSet.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Hi all, I've been trying to determine a good reason why one would use .TableName when the name of the DataTable variable is required anyway and .TableName is optional. Seems that having spent 10 minutes googling, gave me good enough reason to post here what seems like should be an easy question to answer...... I'm assuming it is the same type of situation one would encounter using ProEngineer (CAD). One could name a part with its part name (which would be the file name) and also have an optional "common name". So you could have 012569.prt which has a common name of Bolt. However, in my opinion, have different nomenclature for the same item is usually a "state of confusion" waiting to happen. Thanks!
- In case of a collection of them. 1) For when one is passed into a method. etc.
-
- In case of a collection of them. 1) For when one is passed into a method. etc.
-
Try it.
-
Try it.
PIEBALDconsult wrote:
Try it.
Yes, I knew this would be coming. One can certainly add a table to either a collection or use it in a method without having a formal name (but I don't think that is what you meant, is it)
public class Tables
{
public DataTable tblTest1;
public DataTable tblTest2;
public DataSet dsTables;public Tables() { dsTables = new DataSet(); tblTest1 = new DataTable(); tblTest2 = new DataTable(); dsTables.Tables.Add(tblTest1); dsTables.Tables.Add(tblTest2); } public void ShowTables() { DataTableCollection tables = this.dsTables.Tables; foreach (DataTable tbl in tables) Console.WriteLine(tables.IndexOf(tbl).ToString()); } } public static class Program { static int Main(string\[\] args) { Tables coll = new Tables(); coll.ShowTables(); Console.WriteLine(); Console.ReadLine(); return 0; } }
granted, having the foreach execute on
Console.WriteLine(tbl.TableName);
seems a bit more useful at first glance, so I guess I have my answer.........