Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

SQLite Database, Querying from Table ?

$
0
0

Hi, I am trying to create a table for for user details.
Referring to this example http://docs.xamarin.com/recipes/ios/data/sqlite/create_a_database_with_sqlitenet

With the help of this. I am able to Create a table , Insert a value for particular element.

Struggling to read back (Query) that particular value from a Table.
I am using SQLite for the first time and just know basics of it.

Here is my Code

var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                _pathToDatabase = Path.Combine(documents, "db_sqlite-net1.db");

                using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
                {
                    try{
                    conn.CreateTable<UserData>();
                    Console.WriteLine (" DB Created ");
                    }
                    catch(Exception _dbnot)
                    {
                        Console.WriteLine(" DB not Cr8 "+_dbnot);

                    }
                    var _UserDAta_ary_apena_H = new UserData { Ary_Apena_H = 98 };
                    conn.Insert(_UserDAta_ary_apena_H);


                    var Query_user = conn.Query<UserData>("select * from Item where SourceId = ?", _UserDAta_ary_apena_H);
                    Console.WriteLine(Query_user.ToString());
                }

I am Querying the moment after inserting it to avoid the mismatch of path.
But in both cases... IT throws error of **SQLite Exception thrown, No Such Table : Item **

Why the table is not accessible ? I am not getting any example of how to wrote Query command , To get one particular Item from a Table .

This is how i am making table

using System;
using Mono.Data.Sqlite;

namespace HW
{


    public class UserData
    {

        // Arythmia thresholds
        public static int _position;
        public int position
        {
            get{ return _position;}
            set{_position = value;}
        }

public static int _Ary_Apena_H;
        public int Ary_Apena_H
        {
            get{ return _Ary_Apena_H;}
            set{_Ary_Apena_H = value;}
        }

        public static int _Ary_Apena_L;
        public int Ary_Apena_L
        {
            get{ return _Ary_Apena_L;}
            set{_Ary_Apena_L = value;}
        }
}
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>