DataAdapter.Fill to specific table in dataset

2019-08-05 07:53发布

问题:

I am trying to make use of DataAdapter, unfortunately stuck with straight ADO.Net, and all of the examples I see have a call like this:

dataAdapter.Fill(dataSet, "TableName");

I want to do a fill in that manner, meaning the data goes into a named table, so that I can properly manage the tables later on in the cycle.

Unfortunately, it appears that that method signature no longer exists, and I am struggling a bit to figure out how to name the table in the DataSet properly. Is there a preferred method for doing this now? Or did MS just scrap this method of interacting with your DataSet?

回答1:

How about something like this ?

    DataTable myTable = new DataTable("MyTable");
    adapter.Fill(myTable);
    ds.Tables.Add(myTable);

One more thing, the method signature you mentioned does exist. You can find the method reference here.