static void Download_Macro(string URL, Bachlor_EssayEntities db) { string India_GDP = URL; WebClient streamUrl = new WebClient(); streamUrl.BaseAddress = India_GDP; string URI = India_GDP; Stream data = streamUrl.OpenRead(URI); StreamReader reader = new StreamReader(data); while (reader.Peek() > 0) { string s = reader.ReadLine(); string[] data_string = s.Split(','); India_GDP g = new India_GDP(); double c; bool can = double.TryParse(data_string[1], out c); if (!can) { continue; } g.Date_of_GDP = Convert.ToDateTime(data_string[0]); g.GDP = Convert.ToDouble(data_string[1]); db.India_GDP.Add(g); } data.Close(); reader.Close(); db.SaveChanges(); Console.WriteLine("India Yields Done"); }
static void Download_Macro(string URL, Bachlor_EssayEntities db) { string India_GDP = URL; WebClient streamUrl = new WebClient(); streamUrl.BaseAddress = India_GDP; string URI = India_GDP; Stream data = streamUrl.OpenRead(URI); StreamReader reader = new StreamReader(data); while (reader.Peek() > 0) { string s = reader.ReadLine(); string[] data_string = s.Split(','); India_GDP g = new India_GDP(); double c; bool can = double.TryParse(data_string[1], out c); if (!can) { continue; } g.Date_ = data_string[0]; g.GDP = Convert.ToDouble(data_string[1]); db.India_GDP.Add(g); } db.SaveChanges(); data.Close(); reader.Close(); }