I’ve been looking for solutions since yesterday and I can’t seem to find any. It always says there’s no such table when I try to insert a record on my database.
Error Details:
Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain)
Mono.Data.Sqlite.SqliteCommand.BuildNextCommand ()
UnityEngine.EventSystems.EventSystem:Update()
This is my code:
connectionString = “URI=file:” + Application.persistentDataPath + “/ReportCards.sqlite”;
string filepath = Application.persistentDataPath + “/” + “ReportCards.sqlite”;
if (!File.Exists (filepath))
{
WWW loadDB = new WWW ("jar:file://" + Application.dataPath + "!/assets/" + "ReportCards.sqlite");
while (!loadDB.isDone) {}
File.WriteAllBytes (filepath, loadDB.bytes);
}
connectionString = "URI=file:" + filepath;
dbcon = new SqliteConnection (connectionString);
dbcon.Open ();
private void InsertScore(string name ,int score, int time, string remarks)
{
if (playerScore >= 5 && playerScore<= 26)
{
remarks = "EXCELLENT";
}
else if (playerScore == 4)
{
remarks = "OUTSTANDING";
}
else if (playerScore == 3)
{
remarks = "VERY GOOD";
}
else if (playerScore == 2)
{
remarks = "GOOD";
}
else if (playerScore == 1)
{
remarks = "FAIR";
}
else if (playerScore == 0)
{
remarks = "NEEDS IMPROVEMENT";
}
using (IDbConnection dbConnection = new SqliteConnection (connectionString))
{
dbConnection.Open ();
using (IDbCommand dbCmd = dbConnection.CreateCommand ())
{
string sqlQuery = String.Format ("INSERT INTO LetterRecognition(Name,Score,TimeConsumed_Seconds,Remarks)VALUES(\"{0}\",\"{1}\",\"{2}\",\"{3}\")" ,name,score,time,remarks);
dbCmd.CommandText = sqlQuery;
dbCmd.ExecuteScalar ();
dbConnection.Close ();
}
}
}