public static DataTable GetDataTable(int key) { Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(LocalSqlConn()); string sqlCommand = "select * from accessControl where sitekey='" + key + "' and is_authenticate=1"; DbCommand DBcmd = db.GetSqlStringCommand(sqlCommand); DBcmd.CommandType = CommandType.Text; DataSet ds = db.ExecuteDataSet(DBcmd); return(ds.Tables[0]); }
///-------------------------------------------------------------------------------- /// <summary>This method executes a sql statement using a data reader (to be used /// for get operations. The connection should be closed by the user.</summary> /// /// <param name="sqlStatement">The Sql statement to be executed.</param> /// /// <returns>A IDataReader with query results.</returns> ///-------------------------------------------------------------------------------- public DbDataReader ExecuteRawSqlReader(string sqlStatement) { DbCommand command = null; DbDataReader reader = null; try { // build the command and execute the reader for get operations command = _database.GetSqlStringCommand(sqlStatement); command.Connection = Connection; command.CommandTimeout = DBOptions.CommandTimeout; reader = (DbDataReader)_database.ExecuteReader(command); } catch (Exception ex) { bool reThrow = ExceptionHandler.HandleException(ex); if (reThrow) { throw; } } return(reader); }