Search This Blog

Friday, February 21, 2014

Get all services C#

C# > ServiceProcess > Service Controller

It is a Windows service that allows you to connect to a service.
You can manipulate it or get information about it.

Example:
Get list of all services

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public class clsService
    {
        public string Name { get; set; }
        public string Type { get; set; }
        public string Status { get; set; }
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ServiceController[] scServices;
            scServices = ServiceController.GetServices();
            List<clsService> lcs = new List<clsService>();
            foreach (ServiceController sc in scServices)
            {
                clsService cs = new clsService();
                cs.Name = sc.ServiceName;
                cs.Type = sc.ServiceType.ToString();
                cs.Status = sc.Status.ToString();
               
                lcs.Add(cs);
            }
            dgv.DataSource =lcs ;
        }
    }
}





Linq to SQL equivalent to TOP

C# > LINQ > Take

Take returns the first specified number of elements.

Example
Linq to SQL equivalent to TOP

var query = from q in dc.Queries.OrderBy(f => f.name).Take(10)






Thursday, February 20, 2014

Oracle DBMS_SCHEDULER

Oracle >  SYS.DBMS_SCHEDULER 

The DBMS_SCHEDULER package provides a collection of scheduling functions and procedures.







Wednesday, February 19, 2014

Oracle create job example

Oracle SYS.DBMS_SCHEDULER > CREATE_JOB

The CREATE_JOB procedure creates a single job. You can create multiple jobs using the CREATE_JOBS procedure.


Example:

Oracle create job example


BEGIN
    SYS.DBMS_SCHEDULER.CREATE_JOB (
            job_name => '"db"."job"',
            job_type => 'PLSQL_BLOCK',
            job_action => 'delete from item',
            number_of_arguments => 0,
            start_date => TO_TIMESTAMP('19-FEB-14 04.51.50.316000000 PM', 'DD-MON-RR HH.MI.SS.FF AM'),
            repeat_interval => 'FREQ=DAILY;BYHOUR=3',
            end_date => NULL,
            job_class => 'DEFAULT_JOB_CLASS',
            enabled => false,
            auto_drop => true,
            comments => NULL);


END;






sys.schemas SQL Server example

SQL Server > Catalog Views > sys.schemas

Gets information about database schema.

Example:

select * from sys.schemas

Result






Tuesday, February 18, 2014

Timestamp to date Oracle

Oracle > Timestamp > To Date

select * from your_table
where
TO_DATE (TO_CHAR (timestamp_date, 'YYYY-MON-DD'),'YYYY-MON-DD') = '18-FEB-2014'
 











Thursday, February 13, 2014

sys.data_spaces SQL Server

SQL Server > Catalog Views > sys.data_spaces

Return info for each data space.

Example

select * from sys.data_spaces