Search This Blog

Wednesday 30 January 2013

To display number of sales for each day from begin date or Sql query to Group by day in sql server

SELECT DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0) AS CreatedOn
    ,COUNT(SMD.CreatedDate) as [Count]       
    FROM TableName SMD
    GROUP BY DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0)

Monday 28 January 2013

How can you retrieve a reference to the current application domain?MCTS 70-536 Sample Example


A.  AppDomain ad = AppDomain.Current;
B.  AppDomain ad = Thread.GetDomain();
C.  AppDomain ad = Thread.CurrentThread.CurrentDomain;
D.  AppDomain ad = AppDomain.GetCurrentDomain();

Sunday 27 January 2013

You need to ensure that when the ProcessingComplete event is raised, an instance of the ProcessComplete class is provided to event subscribers. Which base class should you use for the ProcessComplete class?



A. IEnumerable(Of Order)
B. CollectionBase
C. EventArgs
D. Attribute

You need to ensure that dates and numbers are displayed correctly for each user based on location. Which code segment should you add to line GL08 of the Global.asax file?



·         CultureInfo info = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
info = CultureInfo.CreateSpecificCulture(culture);
·         System.Globalization.CultureInfo cultureInfo = cultureInfo.GetCultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
·         System.Globalization.CultureInfo cultureInfo = cultureInfo.CreateSpecificCulture();
(culture);System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;


·         Dim cultureInfo As System.Globalization.CultureInfo =
New System.Globalization.CultureInfo(culture)                             System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo

• You need to log an entry in a custom event log when the EmailSenderService service is started and stopped. What should you do? (Each correct answer presents part of the solution. Choose three.)



A. Add the following code segment to line PO22 of the Poller.vb file:
EventLog.WriteEntry("EmailSenderService", "Stopped", EventLogEntryType.Information)
B. Add the following code segment to line PO12 of the Poller.vb file:
EventLog.WriteEntry("EmailSenderService", "Started", EventLogEntryType.Information)
C. Add the following code segment to line PO22 of the Poller.vb file:
EventLog.WriteEntry("Application", "EmailSenderService:Stopped",
EventLogEntryType.Information)
D. Add the following code segment to line ES10 of the EmailSenderService.vb file:
EventLog.CreateEventSource("Application", "EmailSenderService")
E. Add the following code segment to line PO12 of the Poller.vb file:
EventLog.WriteEntry("Application", "EmailSenderService:Started",
EventLogEntryType.Information)
F. Add the following code segment to line ES10 of the EmailSenderService.vb file:
EventLog.CreateEventSource("EmailSenderService", "EmailLog")

Monday 7 January 2013

To count total number of objects is created for any Class in c# or Asp.net

public class Class1
    {
        static int Count = 0;

        public Class1()
        {
            Count++;
        }

        ~Class1()
        {
            Count--;
        }

        public static int getCount()
        {
            return Count;
        }

    }

class Program
    {
        static void Main(string[] args)
        {

            Class1 obj;

            for (int i = 0; i < 10; i++)
            {
                obj = new Class1();
                Console.WriteLine("Current Count" + Class1.getCount());
            }

            Console.ReadLine();
        }
    }

To count controls Names in page in asp.net

foreach (Control c in Page.Controls)
        {
            if (c.Controls.Count > 0)
            {
                foreach (Control c2 in c.Controls)
                {
                    lbl.Text += c2.GetType().Name + "<br/>";                  
                }
            }
        }

Thursday 3 January 2013

second highest salary in sql without using top and with using top in sql server


--Second hightest Salary without using top
SELECT* FROM emp e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.sal))FROM emp e2
WHERE e2.sal >= e1.sal)

SELECT TOP 1 sal
FROM (SELECT DISTINCT TOP 2 sal FROM emp ORDER BY sal DESC) a
ORDER BY sal

second lowest salary in sql without using top and with using top

--Second lowest Salary
SELECT * FROM emp e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.sal))FROM
emp e2 WHERE e2.sal <= e1.sal)

SELECT TOP 1 sal
FROM (SELECT DISTINCT TOP 2 sal FROM emp ORDER BY sal ) a
ORDER BY sal DESC
Just change the number u can get n th salary for Employee

with cts as
(
select Name,rn=ROW_NUMBER() over (order by Salary desc) from SalaryTable 
)
select Name from cts where rn in (2,5)