Get an Object reference from string?

  • Thread starter Thread starter Code Blue
  • Start date Start date
C

Code Blue

Hi,

In C#, is it possible to obtain an object reference from a string
representation of the object's name?

for example, if I have a TableName = "TblName", and the dataAdapter
associated with that table is called "daTblName", however, I will not know
the TableName till run time.

so at run time, the user will have 20 tablenames to choose from on a page,
and I will pass the chosen table name as a QueryString
(Table.aspx?tablename="TblName"), so I don't have a reference to the data
adapter referring to this particular table, but I know the data adapter's
name.

Is it possible, knowing that the data adapter's object name, to get a
reference to it at run time, perhaps by using Reflection?

Thanks,

CB
 
Ok, I think that using Remoting or Reflection is overkill here, if not
impossible. I guess the best way is to use a hashtable to associate the
tables with their data adapters.

however, I am a little surprised that no simple method exists to do this.

CB
 
Back
Top