0
private string connectionString = "URI=file:" + Application.dataPath + "/Ooredoo_Nov16.sqlite";
void Start()
{
ClearDb ();
CreateDb ();
WriteToDb ("abc","a","1","10");
GetFromDb ();
}
private void WriteToDb(string code, string classs,string id,string status) 
{
using (IDbConnection dbConnection = new SqliteConnection (connectionString))
{
dbConnection.Open ();
using (IDbCommand dbCmd = dbConnection.CreateCommand ())
{
stringsqlQuery=String.Format(“insertintoQrCodeList(code,class,id,status)values(\”{0}\”,\”{1}\”,\”{2}\”,\”{3}\”)”,code,classs,id,status);
dbCmd.CommandText = sqlQuery;
dbCmd.ExecuteScalar ();
dbConnection.Close ();
}
}

like the function WriteToDb() i have also created function for ClearDb,CreateDb,GetFromDb

when i play it in unity it works perfectly but when i make a build in android and windows it is not accessing the database. As per the tutorial about set highscore data base in unity – https://www.youtube.com/watch?v=wV-dKxJU-0Y&list=PLX-uZVK_0K_7NmsYfe2BTOk_IamWC2kU3∈dex=4

i have already added all the dll ..still i cant access the database following dlls have been added libsqlite3, sqlite3, SQLite3.system.data

is this path -"URI=file:" + Application.dataPath + "/Ooredoo_Nov16.sqlite"; valid for builds

this is my output_log file for windows build

Begin MonoManager ReloadAssembly Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Assembly-CSharp-firstpass.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Assembly-CSharp-firstpass.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Assembly-CSharp.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Assembly-CSharp.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.UI.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.UI.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.Networking.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\UnityEngine.Networking.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\ICSharpCode.SharpZipLib.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\ICSharpCode.SharpZipLib.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\LitJson.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\LitJson.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Mono.Data.Sqlite.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\Mono.Data.Sqlite.dll into Unity Child Domain Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.Data.dll (this message is harmless) Loading C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.Data.dll into Unity Child Domain - Completed reload, in 0.050 seconds Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.Core.dll (this message is harmless) Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.dll (this message is harmless) desktop: 1366x768 60Hz; virtual: 1366x768 at 0,0 Initializing input.

XInput1_3.dll not found. Trying XInput9_1_0.dll instead... Input initialized.

Initialized touch support.

UnloadTime: 0.708009 ms Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.Transactions.dll (this message is harmless) Platform assembly: C:\Users\Arjun\Desktop\projects recieved\Unity example - Copy\Spinner\SpinnerWindows_Data\Managed\System.Xml.dll (this message is harmless) SqliteException: SQLite error no such table: QrCodeList at Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain) [0x00000] in :0 at Mono.Data.Sqlite.SqliteCommand.BuildNextCommand () [0x00000] in :0

(Filename: Line: -1)

Setting up 1 worker threads for Enlighten. Thread -> id: f78 -> priority: 1

3
  • What did directory did you place the libsqlite3.sqlite3,SQLite#,system.data DLL's? Commented Nov 10, 2016 at 9:03
  • i have placed the dll files in my plugins folder Commented Nov 10, 2016 at 9:07
  • libsqlite3, sqlite3, SQLite3.system.data Commented Nov 10, 2016 at 9:08

1 Answer 1

1

This is because there are DLL's in the editor that are not in your build. For accessing databases they are usually the following: I18N.dll, I18N.CJK.dll, I18N.MidEast.dll, I18N.Other.dll, I18N.Rare.dll, and I18N.West.dll. If you installed Unity in the default location, these can all be found at C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0. Just create a new folder in your assets folder named "Plugins" and copy all the above DLL's into that new plugins folder.

Since you are using SQLite, you may also have to add the System.Data.dll from the same folder as stated above.

In the future, you should check your output_log.txt file for the exact error message. For a windows build this is found at EXECUTABLE_NAME_Data/output_log.txt

Sign up to request clarification or add additional context in comments.

5 Comments

i have already added all the dll ..still i cant access the database following dlls have been added libsqlite3.sqlite3,SQLite#,system.data
libsqlite3, sqlite3, SQLite3.system.data
@Martinj Reading your output log file, the following error stood out to me: SqliteException: SQLite error no such table: QrCodeList at Mono.Data.Sqlite.SQLite3.Prepare .... This makes me believe that, when you build, the path to the database is different, thus causing the table to not be found. Please check that you have a valid file path for your build.
yes when i build the database path will be different ,for windows build their is a certain database path that should be given ,can u help me in getting some reference about building a windows app
@Martinj Take a look at Unity's documentation for Applidation.dataPath. When you build for Windows, save your Executable and EXECNAME_Data folder in a place that makes the file path to the database the same for your build and when running in your editor. For example, move your database and save your build into the directory ABOVE your Assets folder. Then have the file path be Application.dataPath/../database_name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.