简体   繁体   English

从Windows 8应用程序访问远程MySQL数据库

[英]Access remote MySQL database from windows 8 app

I need to access MySQL database which is located in remote server. 我需要访问位于远程服务器上的MySQL数据库。 I need to fetch data and display it in Windows 8 App (HTML/Javascript). 我需要获取数据并将其显示在Windows 8 App(HTML / Javascript)中。 Is there any API or JS framework available which can access remote database. 是否有可用的API或JS框架可以访问远程数据库。

I don't want to store database in windows 8 app, I just need to retrieve it from remote. 我不想将数据库存储在Windows 8应用程序中,只需要从远程检索它即可。

创建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. 根据Microsoft在其示例中提出的设计模型以及对高响应性应用程序的需求,将数据导入Windows 8应用程序的首选方法是通过Web服务。 This allows you to do things like use the async/await keywords so that your application can stay responsive while getting data. 这使您可以执行诸如使用async / await关键字之类的操作,以便您的应用程序在获取数据时可以保持响应状态。 There's very little reason to use a database over the web service. 几乎没有理由在Web服务上使用数据库。

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 您应该在此处查看HTML / Javascript应用程序的数据使用示例: http : //msdn.microsoft.com/en-us/library/windows/apps/hh974582.aspx

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

I used MySQL connector look this example: 我用MySQL连接器看这个例子:

https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_connector_net 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 到目前为止,我尚未在远程数据库上进行测试,但可以在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. 好吧,最近我对Windows应用商店应用程序和Php进行了一些调整,这是我想出的内容,但是它可以帮助您起步。

You can use MySQL with Php and then echo out the data. 您可以将MySQL与Php结合使用,然后回显数据。 This is from where JavaScript / HTML windows store can fetch the data by using JQuery. 这是JavaScript / HTML窗口存储库可以使用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. 请记住,这只是通过PHP从MySQL访问数据的未经授权的方式。

The HTML can be for default.html HTML可以是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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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