We help IT Professionals succeed at work.

How do I decalre a new DataTable whose name is based on a string value

tatton777
tatton777 asked
on
Medium Priority
225 Views
Last Modified: 2010-04-16
I had a string called zDefinedType, I want my DataTable to be able to dynamically name itself after the string.

PSEUDOCODE

string zDefinedType = "Generic";
DataTable textValueOf(zDefinedType) = New DataTable();

Any Ideas?
Comment
Watch Question

athapaCEO / CTO
Top Expert 2005
Commented:
I doubt that is possible. You could create a new table and add that to hashtable with zDefineType as a key and then you could access that table with that name. I'm not sure what exactly are you trying to do. If you could provide more info on what you are trying to achieve then I could help more.

AT

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
Does this not work?
      string strTableName = "test";
      DataTable myTable = new DataTable(strTableName);
      Console.WriteLine("table Name: {0}", myTable.TableName);

Andy

Commented:
Up to tatton777 really; I think both athapa and myself offer solutions, though we both needed more info if they weren't sufficient.

A.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.