Exemplo n.º 1
0
 public void MyAction()
 {
     Dataxml data = new Dataxml();
     data.AfisareStatics();
 }
Exemplo n.º 2
0
        static void Main()
        {
            try
            {
                XmlDocument xml = new XmlDocument();
                xml.Load("https://portal.vietcombank.com.vn/Usercontrols/TVPortal.TyGia/pXML.aspx");

                string        cnnstr;
                SqlConnection cnn;
                cnnstr = "Data Source=LAPTOP310\\SQLLUANTT;Initial Catalog='';Integrated Security=True";
                cnn    = new SqlConnection(cnnstr);
                cnn.Open();

                XmlNodeList DateTimexml;
                DateTimexml = xml.SelectNodes("/ExrateList/DateTime");

                XmlNodeList Dataxml;
                Dataxml = xml.SelectNodes("/ExrateList/Exrate");

                for (int i = 0; i <= Dataxml.Count - 1; i++)
                {
                    SqlDataAdapter da = new SqlDataAdapter("INSERT INTO TEST..VCB_EXCHANGE_RATE(DATETIME, CODE, NAME, BUY, TRANSFER, SELL) values('" + DateTimexml.Item(0).InnerText + "','" + Dataxml.Item(i).Attributes["CurrencyCode"].InnerText + "','" + Dataxml.Item(i).Attributes["CurrencyName"].InnerText + "'," + Double.Parse(Dataxml.Item(i).Attributes["Buy"].InnerText.Replace("-", "0")) + "," + Double.Parse(Dataxml.Item(i).Attributes["Transfer"].InnerText.Replace("-", "0")) + "," + Double.Parse(Dataxml.Item(i).Attributes["Sell"].InnerText.Replace("-", "0")) + ")", cnn);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                }

                //MessageBox.Show("Data were added to sql server successful!");
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }