I have DataSet and TableAdapter for the table in that DataSet. The problem is that TableAdapter uses a stored procedure to fill DataTable, but the amount of returned columns can be different.
How can I change the schema of DataTable at runtime to get all the columns from stored procedure?
I have DataSet and TableAdapter for the table in that DataSet. The problem is
Share
In my opinion, drop the idea of using the DataAdapter, it’s completely unnecessary. Do this to get the DataTable instead:
Now it doesn’t matter the # of columns you return from the proc, the datatable will contain all of them.
EDIT: Add the following section to your Web.config file below the
<configuration>section replacing the actual connectionString for yours. You should be able to copy this from the Your Settings file.And now create your SqlConnection as follows:
Notice that “ConnectionString” is the name attribute of the connection string in the Web.Config.
See another example here, in case is not very clear.