Ejemplo n.º 1
0
        public void disp_data()
        {
            //Creates a command for the SQL query
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;

            string query = " SELECT processing_date AS 'Processing Date' ," +
                           " CONCAT('$', amount) AS Amount ," +
                           " CONCAT('$', balance) AS Balance ," +
                           " Action ," +
                           " Description ," +
                           " State FROM CustomerData" +
                           " WHERE STATE IN ( SELECT Description" +
                           "                    FROM TRIGGERS ) " +
                           " UNION " +
                           " SELECT processing_date AS 'Processing Date' ," +
                           " CONCAT('$', amount) AS Amount ," +
                           " CONCAT('$', balance) AS Balance ," +
                           " Action ," +
                           " Description ," +
                           " State FROM CustomerData" +
                           " WHERE Description IN ( SELECT Description" +
                           "                       FROM TRIGGERS);";

            cmd.CommandText = query;



            /*
             * SELECT processing_date AS 'Processing Date',
             *  CONCAT('$', amount) AS Amount,
             *  CONCAT('$', balance) AS Balance,
             *  Action,
             *  Description,
             *  State
             * FROM CustomerData
             * WHERE STATE IN (
             * SELECT Description
             * FROM TRIGGERS)
             * UNION
             * SELECT processing_date AS 'Processing Date',
             *  CONCAT('$', amount) AS Amount,
             *  CONCAT('$', balance) AS Balance,
             *  Action,
             *  Description,
             *  State FROM CustomerData
             * WHERE Description IN (
             * SELECT Description FROM TRIGGERS);
             *
             */

            //Executes the SQL query
            cmd.ExecuteNonQuery();

            //Data Table Read from sql server
            DataTable dt = new DataTable();

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            //Fills the SQL Data by the Data Table
            da.Fill(dt);

            //Gets the Data from the data table and places it into the HTML
            TriggerTable.DataSource = dt;
            TriggerTable.DataBind();
        }