SQLite Database is not working after standalone build

I am trying to make a Standalone Application using SQLite in Unity3D, I am getting a strange problem. I created a database using sqliteadmin, and created a Table named Admin, having field: id, email, password.

I am able to Login using email and password but in Unity Edit Mode.

Its working fine but when i build it and then run it, its not working, I have no idea why?


Here is my code:

using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite;
using System.Data;
using System;
using UnityEngine.UI;

public class DatabaseConnection : MonoBehaviour {

public Text em;
public Text pas;
public static int id;
public static string email ="";
public static string conn ="";
public static string password="";
public static string wrong="Wrong Email/Password !!!";
public Text Wrong;
public GameObject loading;
private ButtonsController bc;
public GameObject loginPanel;

void Start () {

	conn = "URI=file:" + Application.dataPath + "/TMDB.s3db";
	IDbConnection dbconn;
	dbconn = (IDbConnection)new SqliteConnection (conn);
	dbconn.Open ();
	IDbCommand dbcmd = dbconn.CreateCommand ();
	string sqlQuery = "SELECT id, email, password " + "FROM Admin";
	dbcmd.CommandText = sqlQuery;
	IDataReader reader = dbcmd.ExecuteReader ();
	while (reader.Read()) {
		 id = reader.GetInt32 (0);
		 email = reader.GetString(1);
		 password = reader.GetString(2);
		Debug.Log (conn);

	reader.Close ();
	reader = null;
	dbcmd.Dispose ();
	dbcmd = null;
	dbconn.Close ();
	dbconn = null;
	loading.SetActive (false);

public void login()
	if ((em.text == email) && (pas.text == password)) {
		Debug.Log ("Success");
		loading.SetActive (true);
	} else {
		Debug.Log ("Error");
		Wrong.text = wrong.ToString ();


i had the same problem a while ago.
go to your build folder under “Build_Data” folder , there’s your database file , if you have same problem as mine , it should have a size of 0 KB , because it’s empty.
copy the database file from your project , and paste it in your “Build_Data” folder.

Somehow mine fails to read the database at start function. After that it’s fine. I guess that’s because, when I have several scripts that try to access the database. But I still couldn’t figure out why.