简体   繁体   中英

No such table sqlite when execute query on xamarin forms pcl

I have a problem with the reading of the tables on the SQLite database.

my OBJ_User class:

    namespace Fimap.Models
{
    public class OBJ_User
    {
        public int DLR_Id { get; set; }
        public string DLR_Username { get; set; }
        public string DLR_Password_Hash { get; set; }
        public object DLR_Nome { get; set; }
        public string DLR_Cognome { get; set; }
        public int DLR_Tipo { get; set; }
        public string DLR_Azienda { get; set; }
        public object DLR_Telefono { get; set; }
        public object DLR_Email { get; set; }
        public int DLR_Abilitato { get; set; }
        public object DLR_Time_Zone { get; set; }
        public object DLR_Country { get; set; }
        public string DLR_Culture { get; set; }
        public object DLR_Email1 { get; set; }
        public object DLR_MCC_Modello_Alias { get; set; }
        public object DLR_Anagrafica { get; set; }
        public object DLR_Firma { get; set; }
        public bool IsFIMAP { get; set; }
        public bool IsSTANDARD { get; set; }
        public bool IsDealerOrFimap { get; set; } //true dealer - false user
        public object DLR_Tipo_Esteso { get; set; }
        public object DLR_Abilitato_Esteso { get; set; }
    }
}

my interface in pcl project:

public interface IDatabaseConnection
    {
        SQLite.SQLiteConnection DbConnection();
    }

Android

[assembly: Xamarin.Forms.Dependency(typeof(DatabaseConnection_Android))]
namespace Fimap.Droid
{
    public class DatabaseConnection_Android : IDatabaseConnection
    {
        public SQLiteConnection DbConnection()
        {
            var dbName = "FimapDB.db3";
            var path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
            return new SQLiteConnection(path);
        }
    }
}

iOS

[assembly: Xamarin.Forms.Dependency(typeof(DatabaseConnection_iOS))]
namespace App.iOS
{
    public class DatabaseConnection_iOS : IDatabaseConnection
    {
        public SQLiteConnection DbConnection()
        {
            var dbName = "FimapDB.db3";
            string personalFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string libraryFolder = Path.Combine(personalFolder);
            var path = Path.Combine(libraryFolder, dbName);
            return new SQLiteConnection(path);
        }
    }
}

pcl connection (database is right connect):

database = DependencyService.Get<IDatabaseConnection>().DbConnection();

在此处输入图片说明

query:

var test = database.Query<OBJ_User>("SELECT * FROM OBJ_User");

when i launch the query i have this error:

SQLite.SQLiteException: no such table: OBJ_User

在此处输入图片说明

OBJ_User is in the dabatase with one record. Why the connection don't mapping the table ? database variable is right connect to database sqlite, i don't understand because database don't get mapping from sqlite file. Solution ?

if you want other info write me in the comment, i will answer

The SQLite library doesn't know how to map the properties of type object to a sqlite column. The SQLite library supports the following column types by default: string, int, double, byte[], DateTime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM