简体   繁体   中英

Access remote MySQL database from windows 8 app

I need to access MySQL database which is located in remote server. I need to fetch data and display it in Windows 8 App (HTML/Javascript). Is there any API or JS framework available which can access remote database.

I don't want to store database in windows 8 app, I just need to retrieve it from remote.

创建Web服务并在您的应用程序中使用它。

Not sure why the previous post is getting downvoted, but here's a deeper explanation:

As per the design models put forward by Microsoft in its examples and the need for highly-responsive applications, The preferred method for getting data into Windows 8 apps is via web services. This allows you to do things like use the async/await keywords so that your application can stay responsive while getting data. There's very little reason to use a database over the web service.

You should check here for a data usage example with the HTML/Javascript app: http://msdn.microsoft.com/en-us/library/windows/apps/hh974582.aspx

您可以以最佳方式使用WCF服务。

I used MySQL connector look this example:

https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_connector_net

i have not tested on a remote database so far, but works on localhost

Well I recently did some tweaking with Windows store apps and Php and this is what I've come up with it's not much but it can give you a start up.

You can use MySQL with Php and then echo out the data. This is from where JavaScript / HTML windows store can fetch the data by using JQuery.

$.ajax({
    type: "GET" //POST GET your choice
    url: " " //paste the php script that retrieves the data from the database
    success: function (output){
         $('#myDiv').append(data);
    }
});

Please do keep in mind this is just an unauthorized way of accessing data from MySQL through PHP.

The HTML can be for default.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>test</title>
    <script src="/Scripts/jquery-2.0.3.js"></script> 
    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.2.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

    <!-- test references -->
    <link href="/css/default.css" rel="stylesheet" />

    <script src="/js/default.js"></script>
    <script src="/Scripts/myScript.js"></script>

</head>
<body>
   <div id="myDiv">

   </div>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM