@flytoyou

Как добавить запись в таблицу созданную в базе данных sql azure с клиента?

Добрый день
Пытаюсь добавить запись в таблицу созданную в базе данных sql azure но не получается

Приложение windows phone store c#

использую мобильную службу
38c92f834b9d48979a9d6d4315913c28.JPG
вот код

app.xaml.cs

public sealed partial class App : Application
{
public static MobileServiceClient client = new MobileServiceClient("здесь ссылка",
"здесь ключ");

MainPage.xaml.cs

private IMobileServiceTable todoTable = App.client.GetTable();

private async void lol_Click(object sender, RoutedEventArgs e)
{

try
{

TodoItem todoItem = new TodoItem() { Id = "1", Text = "My", Complete = "asd" };
await todoTable.InsertAsync(todoItem);
}
catch(MobileServiceInvalidOperationException ds) { lol.Content = ds; }


}

public class TodoItem
{
public string Id { get; set; }

[JsonProperty(PropertyName = "text")]
public string Text { get; set; }

[JsonProperty(PropertyName = "complete")]
public string Complete { get; set; }
}

что делаю не так ?
  • Вопрос задан
  • 367 просмотров
Пригласить эксперта
Ответы на вопрос 2
ahriman
@ahriman
Технологический евангелист Microsoft
Какую ошибку дает? Код выглядит правильным.
Ответ написан
@flytoyou Автор вопроса
4e995b96d7604470b121c74ff0f7240a.JPG

debug

A first chance exception of type 'Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException' occurred in mscorlib.ni.dll

The program '[4144] App2.exe' has exited with code -1 (0xffffffff).

exeption

Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: The request could not be completed. (Not Found)
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__1d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<>c__DisplayClass14.<b__13>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы