Ejemplo n.º 1
0
        public AccountModel()
        {
            mSqlConnection = new ConnectionModel();

            for (int i = 1; i <= 31; i++)
            {
                daysListItems.Add(new SelectListItem {Text = "" + i, Value = "" + i});
            }
            for (int i = 1930; i <= 2005; i++)
            {
                yearsListItems.Add(new SelectListItem {Text = "" + i, Value = "" + i});
            }
        }
Ejemplo n.º 2
0
        public string GetFromDb(string key, string value, string column, string dbName)
        {
            string returnString="";

            ConnectionModel connectionModel = new ConnectionModel();
            MySqlConnection connection = connectionModel.makeConnection();
            MySqlCommand cmd;
            try
            {
                connection.Open();
            }
            catch (MySqlException e)
            {
                throw e;
            }

            try
            {
                cmd = connection.CreateCommand();
                cmd.CommandText = "SELECT * FROM "+dbName+" WHERE "+key+" LIKE @"+key;
                cmd.Parameters.AddWithValue(key, value);
                cmd.BeginExecuteNonQuery();

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                DataRow[] dr = ds.Tables[0].Select();
                if (dr.Length > 0) returnString = dr[0][column].ToString();
                else returnString = "empty";

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                    connection.Close();
            }
            if (returnString != "") return returnString;
            else if (returnString == "empty") return "empty";
            else return "error";
        }