none
[WPSL]How to Update values in a database RRS feed

  • Question

  • Hi there I'm want to change a value of a data in database for example a bool value and I have this code and changes dont save

    ContextClass context = Database.GetDatabase();
    IQueryable<Database> data = from vid in Database.GetDatabase().DataTable where vid.ID == _id select vid;
    var toChange = data.IsFirstOrDefault();
    toChange.isChanged = true;
    context.SubmitChanges();

    Wednesday, May 20, 2015 8:42 PM

Answers

  • i solved im was using a new context declaration of the database instead the same of the context declared  in the query

    • Marked as answer by ozkarLeo Tuesday, June 2, 2015 4:36 AM
    Tuesday, June 2, 2015 4:36 AM

All replies

  • What type of app are you writing? Please edit your title per Guide to posting: subject line tags

    What sort of database are you using? Where do the Database and ContextClass classes come from?

    Wednesday, May 20, 2015 10:20 PM
  • I updated your title for you. Next time please do so yourself.

    If you need help with that 3rd party article you will need to talk to the author. The code you list doesn't appear to match it and it's still not clear what exactly the Database and ContextClasses are.

    I suspect that your problem may be that you're updating your data object but submitting the context object. There isn't any obvious connection between the two in the code snippet you provide, and without knowing what those classes do internally I don't know if there is an internal connection.

    If you are writing new code I'd strongly recommend you use SQLite. The in-box database (SQL CE) is not present in the current application frameworks. If you do want to use SQLCE then I'd start with the Local database for Windows Phone 8 documentation.

    Thursday, May 21, 2015 9:21 PM
  • i solved im was using a new context declaration of the database instead the same of the context declared  in the query

    • Marked as answer by ozkarLeo Tuesday, June 2, 2015 4:36 AM
    Tuesday, June 2, 2015 4:36 AM