views:

332

answers:

4

Hi folks
I have a client-server project (small project for companies in C#) and the server has a DataSet with some tables (there is no Database for some reasons so we save the DataSet as an XML file).
when the clients connect to the server, the server should send some informations to the client depends on his privileges and some clients must add to or Delete from the DataSet in the server.

I am thinking in Making a new small DataSet and sending it to the client (as xml) but I don't know how to generate a new DataSet with specific tables and rows (I tried to use Linq to DataSet but nothing worked).

My Questions is how can I do that and is this a good solution to send informations to clients ? can you suggest a better scenario to send data to clients(I mean instead of making a new DataSet).

A: 

Why is a dataset being passed around. Web services or WCF is used for exactly this purpose. Why not pass the xml directly instead of converting it to dataset and passing it and then converting it back to xml.

Prashant
the problem is not in passing the information but what I found hard is collecting the proper informations from the Basic DataSet
M.H
I love Stack Overflow. If you come here and ask how to walk, five people will appear out of the woodwork to tell you that running is a superior technology and that the walking thing is so 2008... and perhaps you want to wait for the skipping technology coming out in 2011.
quillbreaker
+1  A: 

Use the DataSet.Merge(DataTable) method.

For example,

DataSet theDataSetToPassAround = new DataSet();
theDataSetToPassAround.Merge(youDataSet.Table[indexOfTheTableToPassAround]);

The Merge method also has an overload that takes array of DataRows, if you want.

24x7Programmer
+2  A: 

Load the DataSet and then save it to a new name. This is your new dataset. You can then load it seperately.

Once you've done that, we'll assume that the new dataset is called ds. You can use ds.Tables.Remove(string) to drop whole tables, and ds.Tables[string].Columns.Remove(string) to remove individual columns. Once you've removed the table elements you don't want, you can remove datarows with ds.Tables[string].Rows.Remove(int).

quillbreaker
Don't forget to ds.AcceptChanges() after deleting rows or they will still be in the dataset.
quillbreaker
thank you quillbreaker that is exactly what I am looking for.
M.H
+1  A: 

If your sending data to the users for them to analyze, review, report on.. then you should use Excel or CSV as the output. There is a bunch of ways to send data back to the user that will open directly in Excel, the one I currently use the most though is NPOI. When I started using the NPOI, I found lots of example on going from a DataTable to Excel. NPOI also supports multiple sheets, if you decide you want to output a DataSet to Excel.

Zachary