I am inserting into my Azure Mobileservice SQL-Database and it works fine but I would like to know if there is an error so I can correct it.
How do I get the status from the InsertAsync
to see if it succeed or failed?
public static MobileServiceClient MobileService = new MobileServiceClient(
"https://YOUR-DOMAIN.azure-mobile.net/",
"YOUR-KEY"
);
static IMobileServiceTable<Product> productTable = MobileService.GetTable<Product>();
Product product = new Product {
name = NPDName.Text,
description = NPDDescription.Text,
price = NPDPriceExkl.Text,
tax = NPDTax.Text,
stock = NPDStock.Text,
available = NPDCBAvailable.Checked,
active = true
};
productTable.InsertAsync(product);
How do i get the status from the InsertAsync to see if it succeed or failed?
InsertAsync
returns a Task
. If you want to know it's status, you need to await
on it. In case it fails, an exception will propagate:
public async Task InsertAsync()
{
Product product = new Product
{
name = NPDName.Text,
description = NPDDescription.Text,
price = NPDPriceExkl.Text,
tax = NPDTax.Text,
stock = NPDStock.Text,
available = NPDCBAvailable.Checked,
active = true
};
await productTable.InsertAsync(product);
}
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.