none
Error SQLite

    Question

  • Hi, can someone help me with this error?

    Code:

    private async void Rueckbsuchen(object sender, RoutedEventArgs e)
            {
    
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection("Marktprodukte.db");
                int result = await conn.ExecuteAsync("Select P_ImVerkauf FROM produkte WHERE ID = ?", new object[] { id });

    Error:

    In SQLite.SQLiteException ist eine Ausnahme vom Typ "mscorlib.ni.dll" aufgetreten, doch wurde diese im Benutzercode nicht verarbeitet.

    Zusätzliche Informationen: Row

    In SQLite.SQLiteExeption an exeption of type "mscorlib.ni.dll" has occurred, but this was not handled in user code. 

    Additional Information: Row


    HResult=-2146233088   Message=Row   Source=MarktAppIPA   StackTrace:        at SQLite.SQLiteCommand.ExecuteNonQuery()        at SQLite.SQLiteConnection.Execute(String query, Object[] args)        at SQLite.SQLiteAsyncConnection.<>c__DisplayClass1a.<ExecuteAsync>b__19()        at System.Threading.Tasks.Task`1.InnerInvoke()        at System.Threading.Tasks.Task.Execute()     --- 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 MarktAppIPA.ProdukteVerkaufDetail.<Rueckbsuchen>d__b.MoveNext()   InnerException: 
    
    
    
    
    
    


    • Edited by Counni Thursday, March 26, 2015 8:40 AM
    Thursday, March 26, 2015 8:11 AM

Answers

  • Hi Counni,

    >>In SQLite.SQLiteException ist eine Ausnahme vom Typ "mscorlib.ni.dll" aufgetreten, doch wurde diese im Benutzercode nicht verarbeitet.

    Perhaps you missed single quote in your query statement, try this:

    int result = await conn.ExecuteAsync("Select P_ImVerkauf FROM produkte WHERE ID='?'", id);

    In my experience, generally, we can query directly a table object using Linq, the following code should work for you:

    Product.cs:

    [Table("produkte")]
    public class Product
    {
            [PrimaryKey, AutoIncrement]
            public int Id { get; set; }
    
            public string P_ImVerkauf { get; set; }
    }

    private async Task SearchIDAsync()
    {
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection("Marktprodukte.db");
    
                var query = conn.Table<Product>().Where(x => x.Id.Equals(id));
                var result = await query.ToListAsync();
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 27, 2015 9:45 AM
    Moderator

All replies

  • I think you have to pass a value to ID in the Select Query..

    Mohan Rajesh Komatlapalli

    Thursday, March 26, 2015 11:09 AM
  • ID  already have a value. 
    protected async override void OnNavigatedTo(NavigationEventArgs e)
            {
                id = Convert.ToInt16(e.Parameter);
    
                await SelectVerkaufItem();
    
            }

    Thursday, March 26, 2015 11:48 AM
  • Hi Counni,

    >>In SQLite.SQLiteException ist eine Ausnahme vom Typ "mscorlib.ni.dll" aufgetreten, doch wurde diese im Benutzercode nicht verarbeitet.

    Perhaps you missed single quote in your query statement, try this:

    int result = await conn.ExecuteAsync("Select P_ImVerkauf FROM produkte WHERE ID='?'", id);

    In my experience, generally, we can query directly a table object using Linq, the following code should work for you:

    Product.cs:

    [Table("produkte")]
    public class Product
    {
            [PrimaryKey, AutoIncrement]
            public int Id { get; set; }
    
            public string P_ImVerkauf { get; set; }
    }

    private async Task SearchIDAsync()
    {
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection("Marktprodukte.db");
    
                var query = conn.Table<Product>().Where(x => x.Id.Equals(id));
                var result = await query.ToListAsync();
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 27, 2015 9:45 AM
    Moderator