protected bool testConnection() { bool connectionSucceed = false; try { mySqlDb.open(); if (mySqlDb.Connection.State == ConnectionState.Open) { connectionSucceed = true; } } catch (MySql.Data.MySqlClient.MySqlException mEx) { ErrorLog.Log(mEx); } finally { mySqlDb.dispose(); } return(connectionSucceed); }
protected List <Entity> getListOfEntity(string selectQuery) { List <Entity> entities = new List <Entity>(); try { db.open(); this.selectQuery = selectQuery; using (command = new MySqlCommand(selectQuery, db.Connection)) using (reader = command.ExecuteReader()) { while (reader.Read()) { Entity entity = new Entity(this.id, fieldsname); int n = fieldsname.Length; for (int i = 0; i < n; i++) { entity.setField(fieldsname[i], reader.GetValue(i)); } entities.Add(entity); } db.close(); } } catch (MySqlException mex) { ErrorLog.Log(mex); } catch (Exception ex) { ErrorLog.Log(ex); } finally { db.dispose(); } return(entities); }