locked
Windows 8 Tile App and get data from SQL Server using WCF Service

    Question

  • Hi All,

    I am creating a new Windows 8 Tile App to display the contents of the database table.
    I am following WCF service approach for my app to talk to SQL Server.
    I did a lot of researches and found few good articles and following this one:

    'Insert, Update and Delete Data in GridView Using WCF Service' on c-sharpcorner (I am not able to add link yet)

    So based on the article, I have created a WCF service and a web application to access the service.
    WCF service returns the DataSet which I am getting into a variable like this (in MainPage.xaml.cs on the web application side): var reviewList = await objServiceClientobjService.GetInWorkReviewAsync(); 

    The 'reviewList' variable gets a whole string of database contents means into a serialized form but I would like it as deserialized form or into a list to display into rows.

    I have been trying to follow the code lines below but none works and System.Data is not supported in Windows 8 and I am using Visual Studio 2012 Express for Windows 8. IEnumerable sequence = dt.AsEnumerable(); OR List list = dt.AsEnumerable().ToList(); OR the basic one - List newList = new List();

    Also, do I need to make any changes to web.config? Please guide where am I possible going wrong?

    Tuesday, April 22, 2014 3:28 PM

Answers

  • There's no object in Windows Store apps that describes a dataset. Create your own classes, then instantiate those classes with information from the dataset. Return those objects in the WCF calls to your application and you'll be able to work with them.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, April 23, 2014 1:04 PM
    Moderator

All replies

  • You should create your WCF services to return objects that your app understands, not datarows or tables.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, April 22, 2014 7:40 PM
    Moderator
  • Hi Matt

    Thanks for reply. I have created WCF service and have added it as a service reference in web application. the database call 'GetInWorkReview' in WCF service is of return type 'DataSet'.

    And the variable 'reviewList' in web application calls the service reference async method like this:

    var reviewList = await objServiceClientobjService.GetInWorkReviewAsync(); 

    and when I check the value in reviewList, this is what it looks like: "112345InWorkReviewABC-ABC-ABC-ABCDarrenSmithDarren Smith2013-08-20T14:52:30.54+01:002013-08-20T14:52:30.54+01:000.50Testtrue2013-08‌​-20T14:52:30.54+......"

    Please help.

                       

    Wednesday, April 23, 2014 9:09 AM
  • There's no object in Windows Store apps that describes a dataset. Create your own classes, then instantiate those classes with information from the dataset. Return those objects in the WCF calls to your application and you'll be able to work with them.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, April 23, 2014 1:04 PM
    Moderator