?
Solved

DataTable in Json format

Posted on 2012-03-09
2
Medium Priority
?
1,442 Views
Last Modified: 2012-03-10
Hello,

I am using Visual Studio 2010, Visual C#, .NET framework 4.0.

I have app in IIS. All my methods looks something like this:


        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json)]
        public string Select()
        {            
            return "Hello World";
        }

And the work fine - the only problem is how to return DataTable in Json format?

I've found this topic: http://schotime.net/blog/index.php/2008/07/27/dataset-datatable-to-json/

But, nothings comes back from the server. The dictionary<string, object> is created, but nothing is returned from server.

I need to return DataTable in Json format and the (on the client) convert this back to DataTable and show in DataGrid (Windows forms).


Regards, Frenky
0
Comment
Question by:AntonioRodrigo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 37705022
Frankly, Frenky, I would use a business object, instead of a DataTable.  You can apply a DataContract to the class, and DataMember to the members, and return a list of those objects.
0
 

Author Closing Comment

by:AntonioRodrigo
ID: 37705639
Yes, very good point. And that list of object I can map to DataTable on the client. I've also found one solution by myself: put DataTable into MemoryStream and return MemoryStream.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question