5

Hi I am trying to insert a SQLite database on my application but when i try and call values from it i am recieving this error

DllNotFoundException: sqlite3
Mono.Data.Sqlite.SQLite3.Open (System.String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool)
Mono.Data.Sqlite.SqliteConnection.Open ()
MuHC.Start () (at Assets/Scripts/TestScripts/MuHC.cs:13)

I have followed this topic here. http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.html

and have the exact same heriarchy and code. (just incase here is my code)

using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite; 
using System.Data; 
using System;

public class MuHC : MonoBehaviour {
    void Start () {
    // Use this for initialization
    string conn = "URI=file:" + Application.dataPath + "/MyAPPA.s3db"; //Path to database.
    IDbConnection dbconn;
    dbconn = (IDbConnection) new SqliteConnection(conn);
    dbconn.Open(); //Open connection to the database.
    IDbCommand dbcmd = dbconn.CreateCommand();





    string sqlQuery = "SELECT QuestionId,QuestionText,InputId,OptionChoiceName,QuestionOptionId,NextQuestion " + "FROM GetQuestions";
    dbcmd.CommandText = sqlQuery;
    IDataReader reader = dbcmd.ExecuteReader();


    while (reader.Read())
    {
        int QuestionId = reader.GetInt32(0);
        string QuestionText = reader.GetString(1);
            int InputId = reader.GetInt32(2);

            Debug.Log( "QuestionId= "+QuestionId+"  QuestionText ="+QuestionText+"  InputId ="+  InputId);
    }

    reader.Close();
    reader = null;
    dbcmd.Dispose();
    dbcmd = null;
    dbconn.Close();
    dbconn = null;




}
}

I have the database in all the correct areas and the name for the db is correct. My Herieacrhy

Terry
  • 989
  • 8
  • 29
albaslayer
  • 103
  • 1
  • 7
  • Please, pay attention to the tags you use with the question. They are often a primary source of people who answer your question, and if you don't use correct tags, you won't get as much relevant attention. – Max Yankov May 11 '15 at 11:15
  • This recent question is very similar: http://stackoverflow.com/questions/30163518/dllnotfoundexception-unity3d-plugin – Max Yankov May 11 '15 at 11:16
  • My tags are correct its c# unity and sqllite ? I don't know if its my code or if it's the database or if its the dll ? thats why i included the error code – albaslayer May 11 '15 at 11:18
  • 5
    Unity and Unity3D are different things, you used Unity which is 'a lightweight, extensible dependency injection container for .NET with support for interception.' while you meant unity3d which is the game engine. – HoloLady May 11 '15 at 11:46
  • 1
    I won't call this an answer, but I recently had *tremendous* difficulty getting a DLL plugin to work with Unity3d in Windows 8. So much so that I wound up simply using another computer, running Windows 7, and it worked just fine. If you're on Windows 8, try a different computer/OS – Zach Thacker May 11 '15 at 12:45

1 Answers1

-1

You have to put the sqlite3.dll in your Assets/Plugins folder.

frogatto
  • 28,539
  • 11
  • 83
  • 129
TiagoH
  • 65
  • 10
  • sorry, i only saw now that the link you put in your question already say this, but maybe you forgot? – TiagoH Aug 14 '15 at 11:55