Search This Blog

Sunday, November 10, 2013

DataTable C#

C# > System.Data   > DataTable

DataTable is a table in memory data.
When accessing DataTable objects in DataSet they are case sensitive.
We can display data from it  in controls such as DataGridView.

Properties:

Columns:         collection of columns
Rows:              collection of rows
DefaultView:   customized view of the table that may include a filtered view, or a cursor position.


Example:

   Create a new DataTable   

    System.Data.DataTable table = new DataTable("myTable");

Other examples:




System.Data namespace C#

C# > System.Data

System.Data namespace contains classes that represent ADO.NET architecture.
ADO.NET efficiently manages data from multiple data sources.

Examples:
  1. Populating DataSet and DataTable




    Friday, November 8, 2013

    Add Columns to DataTable C#

    C# > DataTable  > Add  column

    Using Columns collection we can add columns to DataTable in runtime.

    Example:

    DataTable dt = new DataTable("Product");
    dt.Columns.Add("id",typeof(Int32));
    dt.Columns.Add("name",typeof(string));





    Oracle FOR LOOP

    Oracle > FOR LOOP IN

    The syntax for the FOR Loop In Oracle is:

    FOR loop_counter IN [REVERSE] lowest_number..highest_number
    LOOP
    {.statements.}
    END LOOP;

    Example:

    begin
      for i in 1..10 loop
        DBMS_OUTPUT.PUT_LINE (i);
       end loop ;
    end ;
    /




    Microsoft SQL Server System Views

    Microsoft SQL Server system views provides a collections of system views that expose metadata.



    System Stored Procedures SQL Server

    SQL Server > System Stored Procedures

    Using system stored procedures you can perform many administrative and informational activities.

    Catalog
    Extended
    Mail
    Database Engine




    sp_databases SQL Server

    SQL Server > System Stored Procedures > sp_databases

    sp_databases lists databases that reside in an instance of the SQL Server Database .

    Example:

    USE master;
    GO
    EXEC sp_databases;

    DATABASE_NAME           DATABASE_SIZE               REMARKS
    action_plan        4160       NULL
    master  4864       NULL
    model   2624       NULL
    msdb     13312    NULL
    tempdb                2560       NULL