database connection

Hi is this code correct:

	function GetMissionName(idm){
    var query : String;
	var string1:String;
	connection = "URI=file:Assets/PJI Game.s3db";
    dbcon = new SqliteConnection(connection);
    dbcon.Open(); 
    query = "SELECT MissionName FROM Mission where IDMission="+idm;
    dbcmd = dbcon.CreateCommand();
    dbcmd.CommandText = query; 
    reader = dbcmd.ExecuteReader();
	string1=reader[0].ToString();
	dbcon.Close();
	return string1;
    }

I mean can we write dbcon.Open() …
to connect to a SQLite database?

wouldn’t it be just way faster to look on the SQLLite website for the commannd ? This has nothing to do with Unity.

did you tried this code?

yeah I tried it, it works but when I built the game I had a crash error and in the report I had a violation error so I thought that in unity we have to use another code or something…

there is a thread about SQLLite connection here:
http://forum.unity3d.com/threads/28500-SQLite-Class-Easier-Database-Stuff
see if the problems are similar with yours

thank you :slight_smile:

you’re welcome and good luck!