public static DatabaseSingleton getInstance() { if (DBInstance == null) { DBInstance = new DatabaseSingleton(); } return(DBInstance); }
public List <string> getUserDetails() { string query = "SELECT fullname, address, postcode FROM user WHERE email='" + DatabaseSingleton.getInstance().getEmail() + "'"; List <string> list = new List <string>(); //Open connection if (OpenConnection()) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); System.Diagnostics.Debug.WriteLine(dataReader.FieldCount); // System.Diagnostics.Debug.WriteLine(dataReader.); //Read the data and store them in the list while (dataReader.Read()) { list.Add(dataReader.GetString("fullname")); list.Add(dataReader.GetString("address")); list.Add(dataReader.GetString("postcode")); } //close Data Reader dataReader.Close(); //close Connection CloseConnection(); //return list to be displayed return(list); } else { return(list); } }