开发者

Assign dataraeder value to dataset in asp.net

I want to as开发者_开发知识库sign DataReader value to a DataSet, is there any method which helps to do this?


the easiest way is using DataAdapter and pass your DataSet to its Fill methods like this

MyDataAdapter.Fill(MyDataSet);

if your DataSet contains more than one table you can state which table you will Fill like this

MyDataAdapter.Fill(MyDataSet,"TableName");

if you want to use the DataReader you will have to loop over each record and each cell then create new DataRow that will be added to a DataTable then add this table to your DataSet


SqlDataReader dr;
//Fill the Reader
DataSet ds = new DataSet();
DataTable dt = new DataTable(); 
ds.Load(dr, LoadOption.OverwriteChanges,dt);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜