Unity中的SQLite错误

时间:2015-05-11 11:10:27

标签: c# sqlite unity3d

您好我正在尝试在我的应用程序上插入一个SQLite数据库但是当我尝试从它调用值时我收到了这个错误

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)

我在这里已经关注了这个主题。 http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.html

并拥有完全相同的heriarchy和代码。 (只是这里是我的代码)

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;




}
}

我在所有正确的区域都有数据库,并且db的名称是正确的。 My Herieacrhy

1 个答案:

答案 0 :(得分:0)

您必须将sqlite3.dll放入Assets/Plugins文件夹。