如何使用 C# 创建与 UWP 应用程序和 Azure DB 的基本连接

How to create basic connection with UWP app and Azure DB with C#

我正在尝试将我的 windows phone 应用程序与 azure sql 数据库连接。 我正在学习本教程 here

Microsoft Azure 中的 Web 应用程序收到我按下按钮后发送的请求。 但它不保存任何数据。

microsoft azure 中的移动应用运行良好(参见 here

main.xaml.cs下的代码是:

    IMobileServiceTable<UsernameTB> UsernameTBObj = App.MobileService.GetTable<UsernameTB>();
    private void btnSave_Tapped(object sender, TappedRoutedEventArgs e)
    {
        try
        {
            UsernameTB obj = new UsernameTB();
            obj.Username = txtUsernameField.Text;
            obj.Password = txtPasswordField.Text;

            UsernameTBObj.InsertAsync(obj);
            MessageDialog msgDialog = new MessageDialog("Data Inserted!!!");
            msgDialog.ShowAsync();
        }
        catch (Exception ex)
        {
            MessageDialog msgDialogError = new MessageDialog("Error : " + ex.ToString());
            msgDialogError.ShowAsync();
        }
    }

用户名 TB 有此代码:

 class UsernameTB
    {
        public string id
        {
            get;
            set;
        }
        public string Username
        {
            get;
            set;
        }
        public string Password
        {
            get;
            set;
        }

    }

这里有什么问题?

有很多可能。在后端打开诊断日志记录并使用日志流来监视事件 - 你有没有得到错误。

阅读我在 http://aka.ms/zumobook 的书的第 3 章可能会有所帮助 - 这涉及到实际发生的交易。