SQLite的在Unity错误 [英] SQLite In Unity Error

查看:182
本文介绍了SQLite的在Unity错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中插入一个SQLite数据库,但是当我从它尝试和呼叫值我正在recieving这个错误

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)

我在这里遵循了这一话题。
http://answers.unity3d.com /questions/743400/database-sqlite-setup-for-unity.html

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

和具有完全相同的heriarchy和代码。 (只是柜面这里是我的代码)

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;




}
}

我在所有正确的区域数据库和名称为db是正确的。

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

推荐答案

您必须把sqlite3.dll在你的资产/ Plugins文件夹。

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

这篇关于SQLite的在Unity错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆