I have set up a singleton class to handle all the database functions for my application.
Now in order to show the data the user entered into the database, I’m using an instantiated prefab based on a class of gameobjects, in this case text. I’m trying to put the database data into a list so the prefab can be instantiated, but it keeps saying: Assets/Scripts/DatabaseManager.cs(171,16): error CS0246: The type or namespace name `List’ could not be found. Are you missing a using directive or an assembly reference?
I know I added using System.Collections.Generic, so I’m not sure why it’s saying that. Also, I’m not sure how to call the list to be created.
-
Do I need the using statements on both scripts? The singleton and the main script?
-
How do I call the list to be made and return it?
public void GetOilChangeInfo() { OilChangeList.Clear(); //Clear the list(not needed?) List<OilChange> OilChangeList = DatabaseManager.Instance.GetOilChangeList(); ShowOilChangeInfo(); //This function will display the items from the list and instantiate the prefab. }
On the Singleton:
public List GetOilChangeList()
{
mConnection.Open();
mSQLString = "SELECT * FROM " + SQL_TABLE_OIL_CHANGES;
mCommand.CommandText = mSQLString;
mCommand.ExecuteNonQuery();
mReader = mCommand.ExecuteReader();
while (mReader.Read())
{
OilChangeList.Add(new OilChange(mReader.GetString(0), mReader.GetString(1)));
Debug.Log(mReader.GetString(0) + mReader.GetString(1));
}
mReader.Close();
mConnection.Close();
return OilChangeList;
}
Thanks in advance…