Search This Blog

Monday, November 4, 2013

Working with files in C#

C# > IO

IO allow reading and writing to files and data streams, and types that provide basic file and directory support.

Directory class

Path methods
IO
Examples:





    String Type C#

    C# > Types > String

    String type represents a sequence of Unicode characters and is a reference type.

    Methods


    Example:

    string a = "Hello";
    string b = " world";
    // Append ! to contents of b
    b += "!";
    MessageBox.Show (a + b);




    What is C#






    C# is modern, multi-paradigm,  strongly-typed, object oriented  and high level programming language.
    C# is an elegant language that enables you to build a variety of secure and robust applications that run on the .NET Framework. With C# you can create Windows client or Web applications, XML Web services, distributed components, client-server applications, database applications, etc.

    The language of C# is very easy for anyone familiar with C, C++ or Java.
    System












    Reflection C#

    C# > Reflection 

    Reflection offers the possibility   to describe assemblies, modules and types. It enables you to access the attributes. 
    A compiled C# program is a relational database called metadata.


    Example:

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

    namespace csharp
    {
        public partial class Form1 : Form
        {
            public static int mNumber = 10;
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                Type objType = typeof(Form1);
                FieldInfo field = objType.GetField("mNumber");
                object objValue = field.GetValue(null);
                MessageBox.Show(objValue.ToString());
            }
        }
    }




    Friday, November 1, 2013

    Linked Server (SQL Server)

    SQL Server > Linked Server

    linked server allows the SQL Server Database Engine to execute commands against OLE DB data sources.
    Linked servers are configured to enable the Database Engine to execute a Transact-SQL statement to another instance of SQL Server or another database such as Oracle.
    OLE DB data sources can be configured as linked servers like Microsoft Access and Excel.

    Advantages:
    • access data from outside of SQL Server.
    • execute distributed commands( queries updates, transaction) to  heterogeneous data sources

    Examples:

    Add Microsoft Access as linked server

      Microsoft SQL Server

      Microsoft SQL Server is a relational database management system developed by Microsoft.
      SQL Server supports ANSI SQL, the standard SQL language like all major RBDMS.
      SQL Server contains own SQL implementation named T-SQL.
      SQL Server Management Studio (SSMS) is SQL Server interface tool.




      SQL Server script return the last stored procedures modified in the last n days

      SQL Server > sys.objects > Last modified stored procedures

      Example

      declare @nmb_days int = 10
      SELECT * FROM sys.objects 
      WHERE TYPE = 'P' 
      AND DATEDIFF(D,modify_date, GETDATE()) < @nmb_days