Beispiel #1
0
        //Insert PHOENIX CITY home_price_index statement
        public void InsertPHXrnsa(System.Web.UI.WebControls.ListBox ListBox1)
        {
            //open connection
            if (this.OpenConnection() == true)
            {
                string a, b, c, d, e;

                FRED f = new FRED();

                b = "Phoenix"; // cityName

                c = "Maricopa"; // countyName

                d = f.phxrnsa(); // home_price_index

                a = f.getDate(); // date

                e = "NULL"; // unemployment

                MessageBox.Show(a);

                if (d == "DNF")
                {
                    ListBox1.Text = "PHXrnsa up to date! \n";
                }

                else
                {

                    try
                    {

                        String query = String.Format("INSERT INTO city_stats VALUES('{0}', '{1}', '{2}', '{3}', {4})", a, b, c, d, e);

                        //create command and assign the query and connection from the constructor
                        MySqlCommand cmd = new MySqlCommand(query, connection);

                        //Execute command
                        cmd.ExecuteNonQuery();

                        ListBox1.Text = String.Format("{0} has been updated with PHXrnsa. \n", a);

                    }

                    catch { UpdatePHXrnsa(d, a, ListBox1); }
                }
            }
        }