如何将Xamarin应用程序连接到SQL Azure DB [英] How to connect a Xamarin app to a SQL Azure DB

查看:64
本文介绍了如何将Xamarin应用程序连接到SQL Azure DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个SQL Azure数据库,并且想要将一个应该在Android上运行的新Xamarin应用程序连接到该应用程序. 我是Xamarin的新手,我无法从在线教程中找到一种简单的方法来做到这一点.

I have created an SQL Azure DB and I want to connect a new Xamarin app that's supposed to run on Android, to it. I am new to Xamarin an I couldn't figure out a simple way to do it from the tutorials online.

使用Xamarin应用程序从Azure的SQL数据库中获取数据的最简单方法是什么?

What's the simplest way to fetch data from a SQL DB in Azure, using Xamarin app?

推荐答案

答案

您需要创建一个Azure API应用. Xamarin应用程序将使用此REST API与数据库进行交互.

Answer

You'll need to create an Azure API App. The Xamarin app will use this REST API to interact with the database.

永远不要使用数据库的connection string将移动应用程序直接连接到远程数据库,因为这样可能会破坏数据库.例如,如果移动应用程序用户的互联网连接较差,并且他们直接连接到数据库,则该应用程序可能无法完成执行数据库查询. API将确保不会因互联网连接不佳而导致数据库损坏.

Never connect a mobile app directly to a remote database using the database's connection string, because this opens up the potential for database corruption. For example, if the mobile app user has a poor internet connection, and they are connecting directly to the database, the app may not be able to finish executing a database query. An API will ensure that no database corruption happens due to a poor internet connection.

我有一个示例应用程序和一个演练,其中显示了如何创建Azure API应用程序,如何将其连接到Azure SQL数据库以及如何使移动应用程序与REST API通信.

I have a sample app and a walkthrough here that shows how to create an Azure API App, connect it to an Azure SQL Database and how to have the mobile app communicate with the REST API.

https://github.com/brminnick/XamList

这篇关于如何将Xamarin应用程序连接到SQL Azure DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆