public static void GetShare(DateTime from, DateTime to) { string url = @"http://www.sharesansar.com/previous.php?date={0}"; for (DateTime i = from; i < to; i = i.AddDays(1)) { string date = string.Format("{0}-{1:00}-{2:00}", i.Year, i.Month, i.Day); string html = WebUtilities.ReadString(string.Format(url, date)); DataSet ds = HtmlUtilitites.ConvertHTMLTablesToDataSet(html); DataTable dt = Share.getdDatatableSS(ds); if (dt.Rows.Count > 0) { dt.TableName = "ShareHistory"; DataColumn dc = dt.Columns.Add("InsertedDate"); foreach (DataRow Row in dt.Rows) { Row[dc] = DateTime.Now; } if (!Global.Ds.DoesTableExists(dt.TableName)) { Global.Ds.CreateTABLE(dt, false); } Global.Db.BulkCopy(dt); } else { System.IO.File.WriteAllText("Log.txt", "No Data for : " + date); } } }
public static void GetShare() { string html = WebUtilities.ReadString(@"http://www.nepalstock.com/datanepse/index.php"); DataSet ds = HtmlUtilitites.ConvertHTMLTablesToDataSet(html); DataTable dt = Share.getdDatatable(ds); dt.TableName = "ShareTemp"; DataColumn dc = dt.Columns.Add("InsertedDate"); foreach (DataRow Row in dt.Rows) { Row[dc] = DateTime.Now; } Global.Ds.DropIfExist(dt.TableName); Global.Ds.CreateTABLE(dt, false); Global.Db.BulkCopy(dt); }