Windows Azure
/に関連した質問がありますWindows Phone 8 services
ボタンをタップした後、refresh_button_Tap イベントを使用すると、MessageBox でメッセージが表示されます。
「System.NullReferenceException: オブジェクト参照がオブジェクトのインスタンスに設定されていません。pic.MainPage.d__0.MoveNext() で」
次に、[OK] をタップするだけで、新しいレコードが に表示されAzure Database
ます。
public class UsersTableItem
{
public int Id { get; set; }
[DataMember(Name = "Login")]
public string Login { get; set; }
[DataMember(Name = "Password")]
public string Password { get; set; }
}
public partial class MainPage : PhoneApplicationPage
{
// MobileServiceCollectionView implements ICollectionView (useful for databinding to lists) and
// is integrated with your Mobile Service to make it easy to bind your data to the ListView
//private MobileServiceCollectionView<PicturesTableItem> items;
private IMobileServiceTable<PicturesTableItem> picturesTable = App.MobileService.GetTable<PicturesTableItem>();
private MobileServiceCollectionView<UsersTableItem> items;
private IMobileServiceTable<UsersTableItem> usersTable = App.MobileService.GetTable<UsersTableItem>();
// Constructor
public MainPage()
{
InitializeComponent();
}
private async void InsertUsersTableItem(UsersTableItem UsersTableItem)
{
// This code inserts a new PicturesTableItem into the database. When the operation completes
// and Mobile Services has assigned an Id, the item is added to the CollectionView
try
{
await usersTable.InsertAsync(UsersTableItem);
items.Add(UsersTableItem);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
private void refresh_button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
var usersTableItem = new UsersTableItem {Login = "LOL", Password = "9E32581C5C0D680FFC7D95C370D3260B" };
InsertUsersTableItem(usersTableItem);
}
}
アズール SQL
USE [pic_db]
GO
/**** Object: Table [pic].[UsersTableItem] Script Date: 2013-02-19 22:02:47 ****/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [pic].[UsersTableItem](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Login] [nvarchar](max) NOT NULL,
[Password] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_UsersTableItem] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO
これを解決するには?