1

How to updated sqlite db in xamarin iOS

Used the component SQLite.NET add to component.

I have inserted 10 records into db note.db which do have Table Student

 public class  Student{
    [Primary autoIncrement]
    public  int id {get;set;}
    public  int marks {get;set;}
    public  string grade {get;set;}
    public  string subject {get;set;}
  }

Records have been inserted into table.

I want to updated Marks of Student for xyz id;

var updateMarks = db.Query<Student>("UPDATE Student Set marks  = ? WHERE Stockid = ?",100,stdId);

for(var check in updateMarks)
Console.WriteLine ("AFter Updated {0}", check. marks);

1 Answer 1

4

Reading the Xamarin documentation the answer seems to be in that your NOT suppose to be doing a Query!

  • Execute – Use this method (and not Query ) when you don’t expect rows back from the SQL (such as INSERT, UPDATE and DELETE instructions).

This is on the page Part 3 - Using SQLite

So your updateMarks line would become =>

var updateMarks = db.Execute<Student>("UPDATE Student Set marks  = ? WHERE Stockid = ?",100,stdId);

Execute is the Key here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.