【发布时间】:2015-07-21 20:49:58
【问题描述】:
您好,我正在尝试在我的应用程序中插入 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
并且具有完全相同的层次结构和代码。 (以防万一这是我的代码)
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;
}
}
我在所有正确的区域都有数据库,并且数据库的名称是正确的。
【问题讨论】:
-
请注意您在问题中使用的标签。他们通常是回答您问题的人的主要来源,如果您不使用正确的标签,您将不会获得足够的相关关注。
-
这个最近的问题很相似:stackoverflow.com/questions/30163518/…
-
我的标签是正确的 c# unity 和 sqllite 吗?我不知道它是我的代码还是数据库还是 dll?这就是为什么我包含错误代码
-
Unity 和 Unity3D 是不同的东西,您使用了 Unity,它是“支持拦截的轻量级、可扩展的 .NET 依赖注入容器”。而你的意思是 unity3d,它是游戏引擎。
-
我不会将此称为答案,但我最近在获得一个 DLL 插件以在 Windows 8 中与 Unity3d 一起使用时遇到了巨大的困难。以至于我只是简单地结束了使用另一台运行 Windows 7 的计算机,它工作得很好。如果您使用的是 Windows 8,请尝试使用其他计算机/操作系统