Click here to Skip to main content
15,911,848 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
is there any posibility of storing table values in the dataset without data adapter
Posted

Yes, you can create a DataSet manually and add DataTables as necessary

C#
DataSet ds = new DataSet("myDS");
DataTable dt1 = ds.Tables.Add("Table1");
DataTable dt2 = ds.Tables.Add("Table2");

// assume columns have been created
dt1.Rows.Add(...);
dt2.Rows.Add(...);
 
Share this answer
 
Comments
koolprasad2003 17-Nov-11 8:03am    
Correct, using DataTable we can fill dataset. fill datatable using datareader. 5.
Yes, create a SqlDataReader and convert it to Dataset, follow the link to learn more

convert to dataset:
http://osherove.com/blog/2004/1/22/convert-a-datareader-into-a-dataset.html[^]

convert to datatable:
:)http://www.dotnetcurry.com/ShowArticle.aspx?ID=143[^]
 
Share this answer
 
v2
Yes you can use the DataReader and fill a dataset manually. That's what the DataAdapter is doing under the covers.
 
Share this answer
 
1. You can use DataSet.Load method from an IDataReader.

2. use DataSet.ReadXml fill dataset from an Xml document.
 
Share this answer
 
Comments
Manisha Tambade 17-Nov-11 8:57am    
Reson for my vote 5 to all solutions -Mark,pandya,Mehdi and koolprasad all u have given all possible correct ways.
Member 8129554 16-Apr-13 7:59am    
how can I fill the dataset with out database.. I mean with a table in the code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900