Pages

Thursday, October 27, 2011

How to insert and retrieve datetime data type field in MS SQL Server 05 as ‘dd/mm/yyyy’ date format:





--Create a table in MS SQl server for the demo:
create table test_date
(
--Creating a auto increment column for primary key:
test_id bigint identity(1,1) not null primary key,

--Now creating a column which holds the date values form the input:
holiday datetime

)
--Provide input to the created table in ‘dd/mm/yyyy’ date format:
insert into test_date values(convert(datetime,'28/10/2011',103))

--Select inserted date value in required ‘dd/mm/yyyy’ date format:
select convert(varchar,holiday,103) as [Date in dd/mm/yyy format ] from test_date


You can also perform various operations on date format with the help of following link:









Sunday, March 27, 2011

Example of Escape Sequence in C#.Net:

Here is illustration program, you can find the result by run it !




using System;


namespace tryNew
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("this is use of single quotation mark " + "\'in quotation\'");
            Console.Write("\n");
            Console.Write("this is use of double quotation mark " + "\"in quotation\"");
            Console.Write("\n");
            Console.Write("this is use of Backslash " + "\\ with backslash");
            Console.Write("\n");
            Console.Write("this is use of Backspace " + "---\b with backspace");
            Console.Write("\n");
            Console.Write("this is use of From feed " + "\f with From feed");
            Console.Write("\n");
            Console.Write("this is use of Tab charracter " + "\t with Tab charracter");

            Console.Write("\n");
            string mywords = @"'this is the example which shows that how to avoid escape sequences'";
            Console.Write("this is use of @ to avoid escape sequences  " + mywords);
            Console.Write("\n");
            Console.Write("press Enter to exit");
            Console.Read();


        }
    }
}

Example of multiple Main() methods in C#.Net:


C# Syntax:


using System;
namespace m1
{

    class c1
    {
        public static void Main()
        {
            Console.WriteLine("this is from the class 1 of the namespace 1");
            Console.ReadLine();

        }
    }
    class c2
    {
        public static void Main()
        {
            Console.WriteLine("this is from the class 2 of the namespace 2");
            Console.ReadLine();

        }
    }

}



How to run in console:


C:\>csc manyMain.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

manyMain.cs(16,20): error CS0017: Program 'c:\manyMain.exe' has more than one
        entry point defined: 'm1.c1.c2.Main()'.  Compile with /main to specify
        the type that contains the entry point.
manyMain.cs(7,20): error CS0017: Program 'c:\manyMain.exe' has more than one
        entry point defined: 'm1.c1.Main()'.  Compile with /main to specify the
        type that contains the entry point.

C:\>csc manyMain.cs /main:m1.c1
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.


C:\>manyMain
this is from the class 1 of the namespace 1