Search Unity

SqLite problem

Discussion in 'Editor & General Support' started by DomyZ, Feb 17, 2019.

  1. DomyZ

    DomyZ

    Joined:
    Dec 27, 2017
    Posts:
    1
    Hello,
    I'm trying to add SQLite to an android application, and I'm getting this error.
    Can anyone help, I have been trying to resolve this issue for a couple of days now, and I can't get it to work.
    Any help would be appreciated <3.
    This i my code for the connection.
    Code (CSharp):
    1.  
    2. public class SqLite : MonoBehaviour
    3. {
    4.     private string connectionString;
    5.  
    6.     private IDbConnection dbcon;
    7.  
    8.     void Start()
    9.     {
    10.      
    11.      
    12.        string connectionString = "URI=file:" + Application.persistentDataPath + "/StreamingAssets/DataBase.sqlite";
    13.         //var www = new WWW(connectionString);
    14.         Debug.Log(connectionString);
    15.         dbcon = new SqliteConnection(connectionString);
    16.         dbcon.Open();
    17.  
    18.  
    19.         getData();
    20.     }
    21.  
    22.  
    23.     void Update()
    24.     {
    25.  
    26.     }
    27.     private void getData()
    28.     {
    29.         using (IDbConnection dbConnection = new SqliteConnection(connectionString))
    30.         {
    31.             dbConnection.Open();
    32.  
    33.             using (IDbCommand dbCmd = dbConnection.CreateCommand())
    34.             {
    35.                 string sqlQuery = "SELECT * FROM Users";
    36.                 dbCmd.CommandText = sqlQuery;
    37.  
    38.                 using (IDataReader reader = dbCmd.ExecuteReader())
    39.                 {
    40.                     while (reader.Read())
    41.                     {
    42.                         Debug.Log(reader.GetString(1));
    43.                         //Debug.Log(reader.GetValue(0));
    44.                         //Debug.Log(reader.GetValue(1));
    45.                         //Debug.Log(reader.GetValue(2));
    46.                     }
    47.                     dbConnection.Close();
    48.                     reader.Close();
    49.                 }
    50.             }
    51.         }
    52.     }
    53. }
    54.  
    ERROR:
    (Attached a picture)
     

    Attached Files:

    Last edited: Feb 17, 2019