DataAdapter.Fill to specific table in dataset

六月ゝ 毕业季﹏ 提交于 2019-12-11 13:32:23

问题


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.



来源:https://stackoverflow.com/questions/3160013/dataadapter-fill-to-specific-table-in-dataset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!