locked
Receiving data from my SQL database by ODBC

    Question

  • So I have my SQL database setup online.  I've also been able to connect to my database in Visual Studio using ODBC.  Now I'm just not sure how to actually get any of that information to show up in my app.  I've started looking at WinJS.xhr, but I'm not having much luck.  

    I found this XHR, handling navigation errors, and URL schemes sample that I thought would help.  The project just crashes on me when I click the scenarios I thought would be helpful.  

    Any examples or help would be appreciated.

    Thanks.


    Monday, May 20, 2013 6:14 PM

Answers

  • Hi,

    The definition of Xhr is this :

    Wraps calls to XMLHttpRequest in a promise.

    This means it will only work on a HttpRequest not to a ODBC connection. In your previous post, I exactly mentioned that.

    Apps cannot connect directly to any source using any providers like OBDC, ADOMD, OLEDB or any other connector. that is where the need for a service layer comes in.

    The service layers connects to the source and gets the data using providers like ODBC, OLEDB etc. and then returns the data as a response (may be XML or JSON). In the app side you can consume that response and play around with the data.

    Hope this helps..

    - Girija


    Monday, May 20, 2013 8:58 PM

All replies

  • Hi,

    The definition of Xhr is this :

    Wraps calls to XMLHttpRequest in a promise.

    This means it will only work on a HttpRequest not to a ODBC connection. In your previous post, I exactly mentioned that.

    Apps cannot connect directly to any source using any providers like OBDC, ADOMD, OLEDB or any other connector. that is where the need for a service layer comes in.

    The service layers connects to the source and gets the data using providers like ODBC, OLEDB etc. and then returns the data as a response (may be XML or JSON). In the app side you can consume that response and play around with the data.

    Hope this helps..

    - Girija


    Monday, May 20, 2013 8:58 PM
  • Sorry if you had to repeat yourself, I'm new to this concept.  I just assumed that since I was able to see my database in Visual Studio there had to be some way my code in VS could see it too.  I'll explore options about a RESTful service with WCF on amazon web services. 
    Tuesday, May 21, 2013 1:28 PM
  • Apps are not designed to connect to DB and pull data from them. They can only use web requests to get data in some format (such as JSON/XML).

    So the logic for pulling data from DB should be implemented in the service layer which can use data providers (OLEDB, ODBC, etc) to connect and pull data.

    Apps are supposed to be light weight which means they are supposed to just display the UI and not use complex data retrieval logic.

    - Girija

    Tuesday, May 21, 2013 7:05 PM
  • Okay. So say I setup a server with WCF.  I could use ODBC on Visual Studio on there to pull the data, and then put the service layer code on there to allow my app to get the data?
    Tuesday, May 21, 2013 8:23 PM
  • Yes you can do that... You can choose the WCF to be a REST service (Returns JSON) or XML.

    The WCF should give you all to connect to database and pull data. The App should query the WCF to get data.

    Request flow will be like this :

    App ==> WCF ==> Database

    Data Flow will be :

    App <== WCF <== Database

    Hope this helps...

    - Girija

    Tuesday, May 21, 2013 9:05 PM
  • Yeah it does, I'm just trying to figure out what all I need. So I now have a Windows Server 2008 with IIS setup with WCF functionality installed.  So if I go the REST service route can I actually skip installing Visual Studio altogether and just have my app call my server via static-ip and get the data that way?

    I'm still trying to figure out how to integrate the REST part. 

    FYI:

    I got this information from another source, why do you think he says to avoid WCF? 

    For REST services I would avoid WCF and take a look at WebAPI which is part of ASP.Net MVC now.  With WebAPI and Entity Framework you can create REST services rapidly.

     

    Few samples:

    http://code.msdn.microsoft.com/ASP-NET-Web-API-with-afa30545

    http://code.msdn.microsoft.com/windowsapps/Contact-Manager-Web-API-0e8e373d

    Wednesday, May 22, 2013 7:51 PM