/// <summary> /// Execute the SQL statement returns the result to the DataSet /// </summary> /// <param Name="strSQL"> </ param> /// <returns> DataSet </ returns> public DataSet ReturnDataSet(string strSQL) { DataSet _DataSet = null; try { _TrackerDbConn.Open(); _DataSet = new DataSet(); OdbcDataAdapter _OdbcDA = new OdbcDataAdapter(strSQL, _TrackerDbConn); if (_Parameters != null) { foreach (OdbcParameter param in _Parameters) { _OdbcDA.SelectCommand.Parameters.Add(param); } } if (_WhereParameters != null) { foreach (OdbcParameter param in _WhereParameters) { _OdbcDA.SelectCommand.Parameters.Add(param); } } _OdbcDA.Fill(_DataSet, "objDataSet"); } catch (OdbcException _ex) { // Handle exception. TrackerTools _Tools = new TrackerTools(); _Tools.SetTrackerSessionErrorString(_ex.Message); if (_DataSet != null) { _DataSet.Dispose(); } throw; } finally { _TrackerDbConn.Close(); } return(_DataSet); }
public OdbcDataReader ReturnDataReader(string strSQL) { OdbcDataReader _DataReader = null; try { _TrackerDbConn.Open(); OdbcCommand _cmd = new OdbcCommand(strSQL, TrackerDbConn); if (_Parameters != null) { foreach (OdbcParameter param in _Parameters) { _cmd.Parameters.Add(param); } } if (_WhereParameters != null) { foreach (OdbcParameter param in _WhereParameters) { _cmd.Parameters.Add(param); } } //OdbcDataReader odbcDataReader = _cmd.ExecuteReader(); _DataReader = _cmd.ExecuteReader(); } catch (OdbcException _ex) { // Handle exception. TrackerTools _Tools = new TrackerTools(); _Tools.SetTrackerSessionErrorString(_ex.Message); if (_DataReader != null) { _DataReader.Dispose(); _DataReader = null; } } finally { /// } return(_DataReader); }