When i execute the query below in DB Browser SQL it returns the rows it is supposed to return.
When i try to use the reader.Read() it always returns False,hence it can not enter the while loop.
It does connect to the database and it WILL give me an error if i choose an invalid table/column but no matter what query i use,it will never return anything inside the reader.
Am not sure if my sqlite3.dll is the cause or not,also i dont know if i need sqlite3.def . It was really hard to get x64 versions of them,sqlite3.dll IS for x64 but i dont know if it is the cause of the problem.
Any help?
using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite;
using System.Data;
public class SQLHandler : MonoBehaviour {
void Start()
{
string sqlQuery = "SELECT CardID FROM Cards";
string conn = "Data Source = " + Application.dataPath + "/Tether_Weavers_Database.db; Version=3;";//Path to database.
SqliteConnection dbconn;
dbconn = new SqliteConnection(conn);
SqliteCommand dbcmd = new SqliteCommand(sqlQuery, dbconn);
dbconn.Open(); //Open connection to the database.
Debug.Log("i still go!");
Debug.Log(conn);
SqliteDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
//NEVER GETS HERE
Debug.Log("i cant getin here :(");
string name = reader.GetString(0);
Debug.Log( " name =" + name );
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbconn.Close();
dbconn = null;
}
}