Question by
STE0620 · Dec 08, 2015 at 04:05 PM ·
build-errordatabasesqlite
I Cant Open the Database after build
Hi guys its been a week but i haven’t figure whats the problem on my work. I can’t open the sqlite database after building but it works fine on the unity editor.. Im using unity 5.0.0p2.. here is my code:
using UnityEngine;
using System.Collections;
using System;
using System.Data;
using Mono.Data.Sqlite;
using System.Collections.Generic;
public class DataRuntimeStorage : MonoBehaviour {
private string connectionString;
private List<Dictionary> dictionary = new List<Dictionary>();
public GameObject termPrefab;
public Transform termParent;
void Start ()
{
connectionString = “URI=file:” + Application.dataPath + “/Database/GeoHazardDB.sqlite”;
}
private void GetTerms()
{
dictionary.Clear ();
using(IDbConnection dbConnection = new SqliteConnection(connectionString))
{
dbConnection.Open();
using (IDbCommand dbCmd = dbConnection.CreateCommand())
{
string sqlQuery = “SELECT * FROM Dictionary ORDER BY Term”;
dbCmd.CommandText = sqlQuery;
using (IDataReader reader = dbCmd.ExecuteReader())
{
while (reader.Read())
{
dictionary.Add(new Dictionary(reader.GetInt32(0),reader.GetString(1),reader.GetString(2)));
}
dbConnection.Close();
reader.Close();
}
}
}
}
public void ShowTerms()
{
GetTerms ();
for (int i=0; i<dictionary.Count; i++)
{
GameObject tmpobject = Instantiate(termPrefab);
Dictionary tmpTerm = dictionary[i];
tmpobject.GetComponent<DictionaryScript>().SetTerm(tmpTerm.Term, tmpTerm.Definition);
tmpobject.transform.SetParent(termParent);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Database Error After Building 0 Answers
How to Synchronise between Server Database (MYSQL) and Local database (SQLite) 1 Answer
iOS can't connect to SQLite DB 1 Answer
login system in unity w/ SQLite 0 Answers
Can sqlite sync with database online? 0 Answers