Dynamically Instantiate a Table Adaper Created with a Dataset Generator

476 Views Asked by At

I have a number of stored procedures. I used the .net server explorer and the dataset generator to create table adapter and table pairs.

Now in my code I want to dynamically instantiate these table adapters based on the user selecting a choice from a list (the report of their choice which corresponds to a stored procedure and table adapter).

The problem is I can't seem to instantiate the table adapter properly. The table works fine and when I do the table adapter, I can drill down on the properties at run time and even find and invoke the fill method, but when I try to set the connection string, I can't find it using getproperty. Does anyone have an example that works for how to do this? I've tried a few examples I found online, but nothing seems to work.

1

There are 1 best solutions below

0
On

Figured it out. When .Net creates the table adapter in the code behind for msDataSetGenerator, it declares the Connection property as Friend rather than Public. When I change it to Public, I can get and set it through Reflection like the other properties/methods that were declared public.

Having discovered this, I wonder if there really is a security risk in changing the get/set's for the connection string to public...