hi to all...., i wrote like dis to get "subject name" from my database.cs. I got good result in pc.Now i hav a problem with android.In android i didn't get my "subject name".Plz help me... My code is lik dis. Code (CSharp): void subjectlist(string p){ string connectionString = "URI=file:"+Application.persistentDataPath+"/"+p; dbcon = new SqliteConnection(connectionString); dbcon.Open(); dbcmd = dbcon.CreateCommand(); string sql="select distinct subject_name from topicmaster ORDER BY subject_id"; int count=0; dbcmd.CommandText = sql; reader = dbcmd.ExecuteReader(); while(reader.Read()) { subjectList[count]=reader.GetString(0); count++; } Array.Resize(ref subjectList,count);
And what kind of error do you get? Nothing, a crash ? You forgot to add the var declaration in your piece of code, I guess global vars declared earlier in the file. Also, could you use the code flags to get some more easily readable text ?
Looks more like a pure SQL error rather than a C#/Unity one. Are you sure your connexion is correctly done? And that your database is the good one as well?
Hi ganesh. Your code is syntactically correct. This means that there are only a few reasons that you'd be getting this error. Are you sure that the table name is topicmaster? Are you sure that "p" being passed in has the correct name of the database? It needs to contain the actual name of the database for it to work. For example: If your database name was "mydatabase.db", your connection string line would have to look like this Code (CSharp): string connectionString = "URI=file:"+Application.persistentDataPath+"/" + "mydatabase.db"; Make sure the variable "p" being passed into the function holds the name of the database like in my example above. Also, on a side note, please use code tags when posting segments of code. http://forum.unity3d.com/threads/using-code-tags-properly.143875/