none
How to use Sqlite ExecuteReader in windwos phone 8 using sqlite database ? RRS feed

  • Question

  • Hi i am using windows phone 8 app. i have to check valid user in my table, so am using sqlite datareader.but i am facing some issue given below.

     protected override void OnNavigatedFrom(NavigationEventArgs e)
            {
                if (dbConn != null)
                {
                    /// Close the database connection.
                    dbConn.Close();
                }
            }
            private void Click_Login(object sender, RoutedEventArgs e)
            {
                dbConn = new SQLiteConnection(DB_PATH);
                SQLiteCommand sqCommand = new SQLiteCommand(dbConn);
                if (txtEmailaddress.Text != "")
                {
                    sqCommand.CommandText = "SELECT * FROM Task Where Email=" + "\'" + txtEmailaddress.Text + "\'" + "and Password=" + "\'" + txtPassword.Password + "\'";
                    sqCommand.ExecuteNonQuery();
                     SQLiteDataReader reader = sqCommand.ExecuteReader();// exeception throws here
                    
                }
                
            }

    I got error :

    'SQLite.SQLiteCommand' does not contain a definition for 'ExecuteReader' and no extension method 'ExecuteReader' accepting a first argument of type 'SQLite.SQLiteCommand' could be found (are you missing a using directive or an assembly reference?)  

    I am using Visual Studio 2012. Please help me how to solve in this isse



    • Edited by WPhone07 Wednesday, June 26, 2013 6:40 AM
    Monday, June 24, 2013 5:37 AM

All replies

  • Hi i got the solution...,

    using (var dbConn = new SQLiteConnection(DB_PATH))
                {
                    var existing = dbConn.Query<Userlist>("select * from Userlist Where Email=" + "\'" + txtEmailaddress.Text + "\'" + "and Password=" + "\'" + txtPassword.Text + "\'").FirstOrDefault();
                   
                    if (existing != null)
                    {
    
                        NavigationService.Navigate(new Uri("/Input.xaml?selectedItem=", UriKind.Relative));
    
                    }
                    else
                    {
                        MessageBox.Show("invalid login");
                    }
                }

    Wednesday, July 3, 2013 1:09 PM