简体   繁体   中英

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

I am trying to connect my windows phone application with azure sql db. I am following this tutorial here .

The web app in microsoft azure receives requests I send after pressing the button. but it doesnt save any data.

the mobile app in microsoft azure works fine (see it here )

the code under main.xaml.cs is:

    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();
        }
    }

UsernameTB has this code:

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

    }

whats the problem here?

There are a bunch of things it could be. Turn on diagnostic logging in the backend and use the log stream to monitor for events - do you get errors.

You may benefit from reading Chapter 3 of my book at http://aka.ms/zumobook - this goes into the transactions that actually happen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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