简体   繁体   English

如何从Windows Phone 8应用程序连接到远程MySQL数据库?

[英]How to connect to remote MySQL database from Windows Phone 8 application?

I'm developing application for windows phone 8 and I need to get user data from remote MySQL database. 我正在为Windows Phone 8开发应用程序,我需要从远程MySQL数据库获取用户数据。 This database is also used by the web-application. Web应用程序也使用此数据库。

What is the solution for this problem? 这个问题有什么解决方案? Where I can read some information about using remote data storages with windows phone 8? 在哪里可以阅读有关Windows Phone 8使用远程数据存储的一些信息?

You can use the restsharp client for windows phone. 您可以将restsharp客户端用于Windows Phone。 Its fully documented and a nuget install is also available. 它有完整的文档,并且也提供了nuget安装。 heres the link http://restsharp.org/ 这是链接http://restsharp.org/

A better and simpler way is to perform all the db operations in server side code (like php) and the information can be passed to the php file using a query string and the reverse by echo statement. 更好,更简单的方法是在服务器端代码(如php)中执行所有的db操作,并且可以使用查询字符串和echo by echo语句反向将信息传递到php文件。

var webclient = new WebClient();
webclient.OpenReadAsync(new Uri("http://website.com/filename.php?name=" + myname.Text );
webclient.OpenReadCompleted += new OpenReadCompletedEventHandler(handler);

private void opener(object sender, OpenReadCompletedEventArgs e)
{
    //  throw new NotImplementedException();
    using (var reader = new StreamReader(e.Result))
    {
            string response = reader.ReadLine();

            MessageBox.Show(response);
    }
}

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

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