public static DataTable GetDataTable(IGTDataContext oDC, string sSQL, GTDiagnostics _diag) { DataTable dt = null; try { //IGTDataContext oDC = GTClassFactory.Create<IGTApplication>().DataContext; Recordset oRS = oDC.OpenRecordset(sSQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText); OleDbDataAdapter oDA = new System.Data.OleDb.OleDbDataAdapter(); dt = new DataTable(); oDA.Fill(dt, oRS); oDA.Dispose(); oRS.Close(); } catch (Exception ex) { if (_diag.IsEnabled(GTDiagCat.EE)) { _diag.LogException("CommandUtilities.GetDataTable", ex); } throw ex; } return(dt); }
public static void LogException(GTDiagnostics oDiag, string sMethod, Exception logExc) { try { if (oDiag.IsEnabled(GTDiagCat.EE)) { oDiag.LogException(sMethod, logExc); } } catch (Exception ex) { throw ex; } }
public static Recordset ExecuteQuery(IGTDataContext _dc, String sSql, GTDiagnostics _diag) { Recordset _rs = null; try { int rEffected = -1; _rs = _dc.Execute(sSql, out rEffected, (int)CommandTypeEnum.adCmdText, null); } catch (Exception ex) { if (_diag.IsEnabled(GTDiagCat.EE)) { _diag.LogException("CommandUtilities.ExecuteQuery", ex); } } return(_rs); }
public static String Get_Recordset_Value(Recordset oRS, String sColumn, String sFilterColumn, String sFilter, GTDiagnostics _diag) { string returnString = string.Empty; try { if ((!oRS.EOF) && (!oRS.BOF)) { oRS.MoveFirst(); } while ((!oRS.EOF) || (!oRS.BOF)) { if (!string.IsNullOrEmpty(sFilter)) { if (sFilter == oRS.Fields[sFilterColumn].Value.ToString().Trim()) { returnString = oRS.Fields[sColumn].Value.ToString().Trim(); break; } } else { returnString = oRS.Fields[sColumn].Value.ToString().Trim(); } oRS.MoveNext(); } } catch (Exception ex) { if (_diag.IsEnabled(GTDiagCat.EE)) { _diag.LogException("CommandUtilities.Get_Recordset_Value", ex); } throw ex; } return(returnString); }