且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 Xamarin 应用程序连接到 SQL Azure DB

更新时间:2022-02-28 10:12:53

答案

您需要创建一个 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