public void insertExecl(DataSet rslt) { DataClasses1DataContext conn = new DataClasses1DataContext(); foreach (DataTable table in rslt.Tables) { foreach (DataRow dr in table.Rows) { tblExcel addTbl = new tblExcel() { SID = Convert.ToString(dr[0]), Name = Convert.ToString(dr[1]), Address = Convert.ToString(dr[2]) }; conn.tblExcels.InsertOnSubmit(addTbl); } } conn.SubmitChanges(); //excldr.Close(); //strm.Close(); Console.WriteLine("successfully"); }
public bool InsertXMLData(List <TransactionInfo> transInfo) { bool result = false; try { tblExcel _xml; tblXMLPaymentDetail _details; using (Entities db = new Entities()) { foreach (var item in transInfo) { _xml = new tblExcel(); _xml.Syskey = Guid.NewGuid(); _xml.TransID = item.Id; _xml.TransDate = item.TransactionDate; _xml.RecordStatus = item.Status; db.tblExcels.Add(_xml); foreach (var det in item.PaymentDetailInfo) { _details = new tblXMLPaymentDetail(); _details.Syskey = Guid.NewGuid(); _details.XMLId = _xml.Syskey; _details.Amount = det.Amount; _details.CurrencyCode = det.CurrencyCode; db.tblXMLPaymentDetails.Add(_details); } } db.SaveChanges(); result = true; } } catch (Exception ex) { result = false; } return(result); }