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

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

问题描述

我已经创建了一个 SQL Azure DB,我想将一个应该在 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 DB 获取数据的最简单方法是什么?

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.

切勿使用数据库的连接字符串将移动应用程序直接连接到远程数据库,因为这可能会导致数据库损坏.例如,如果移动应用程序用户的 Internet 连接不佳,并且他们直接连接到数据库,则应用程序可能无法完成执行数据库查询.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天全站免登陆