- Home /
SQLite Database for Android Unity Error
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnitySampleAssets.CrossPlatformInput;
using Mono.Data.Sqlite;
using System.Data;
using System;
public class ShopScript : MonoBehaviour {
public Text txtDamage;
public Text txtAcc;
public Text txtCurrent;
public Text txtMax;
public Text txtDamageUp;
public Text txtAccUp;
public Text txtCurrentUp;
public Text txtMaxUp;
public Sprite img;
private String[] WName;
private String[] WDamage;
private int counter;
private IDbConnection dbconn;
void Start () {
counter = 0;
string connection = "URI=file:" + Application.persistentDataPath + "/MYGAMEDB.s3db";
dbconn = (IDbConnection) new SqliteConnection(connection);
dbconn.Open(); //Open connection to the database.
IDbCommand dbcmd = dbconn.CreateCommand();
string sqlQuery = "SELECT * FROM WeaponShop";
dbcmd.CommandText = sqlQuery;
IDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
//WDamage[counter] = reader.GetString(2);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbconn.Close();
dbconn = null;
}
}
and this Error happen. how to fix it ?
EntryPointNotFoundException: sqlite3_next_stmt Mono.Data.Sqlite.SQLiteBase.ResetConnection (Mono.Data.Sqlite.SqliteConnectionHandle db) Mono.Data.Sqlite.SQLiteBase.CloseConnection (Mono.Data.Sqlite.SqliteConnectionHandle db) Mono.Data.Sqlite.SqliteConnectionHandle.ReleaseHandle () System.Runtime.InteropServices.CriticalHandle.Dispose (Boolean disposing) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs:56) System.Runtime.InteropServices.CriticalHandle.Dispose () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Runtime.InteropServices/CriticalHandle.cs:42) Mono.Data.Sqlite.SQLite3.Close () Mono.Data.Sqlite.SqliteConnection.Close () (wrapper remoting-invoke-with-check) Mono.Data.Sqlite.SqliteConnection:Close () Mono.Data.Sqlite.SqliteConnection.Open () ShopScript.Start () (at Assets/ShopScript.cs:37)
Answer by bibalexwalid · Apr 15, 2019 at 10:58 AM
Tutorial SQLite Unity3d 2018 or hegher( Android , Windows Phone , Windows , IOS, WINRT ) How to Connection Database Sqlite how to Create Table , Select , Insert , Update , Delete , Search
How to read data from on unity Solving all error in unity for assembly reference: 1- error "The type or namespace name Data' does not exist in the namespace 'Mono'. Are you missing an assembly reference?" 2- and error "The type or namespace name MONO' does not exist in the namespace Data'. Are you missing an assembly reference?" - using Mono.Data.Sqlite; - using System; - using System.Data; - using System.IO; - using UnityEngine.UI;
learning how: SQLite Admin to create database and tables ....... SQLite DLL to support unity .s3db extension and compile on unity for windows 32bit or 64bit.
Github example : https://github.com/walidabazo
Video