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).
views:
332answers:
4Why 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.
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.
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).
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.