Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • DataTable in ADO.NET

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 105
    Comment on it

    While working with ADO.NET we use two kinds of approach

    • Connected
    • Disconnected

     

    Connected approach is the one where the database connection is opened and closed.

     

    Disconnected approach is the one where no need to open or close database connection. Buffer is used to get records from the database.

     

     

     

    While taking about disconnected approach data is stored into the buffers.

     

    One of these buffer is DataTable that contains the data of the table at a time.

     

    PROPERTY

    DESCRIPTION

    Columns

    Columns represents all table columns

    Constraints

    All table constraints are represented by constraints

    DataSet

    Dataset for the table is returned by DataSet

    DefaultView

    It is a customized view of the data table

    ChildRelation

    The child relations for the data table is returned by ChildRelation

    ParentRelation

    Returns parent relations for the data table

    PrimaryKey

    This key Represents an array of columns that function as primary key for the table

    Rows

    All rows of the data table

    TableName

    Name of the table

     

     

    METHOD

    DESCRIPTION

    AcceptChanges

    This method commits all the changes made since last AcceptChanges was called

    Clear

    This method will deletes all data table data

    Clone

    This method will creates a clone of a DataTable including its schema

    Copy

    This method will copies a data table including its schema

    NewRow

    This method will creates a new row, which is later added by calling the Rows.Add method

    RejectChanges

    This method will reject all changed made since last AcceptChanges was called

    Reset

    This method will resets a data table's original state

    Select

    This method will gets an array of rows based on the criteria

     

     

    We can use DataTable to buffer data to show it or to manipulate it, see the example below:

    SqlConnection conObj=new SqlConnection("");
    
    SqlDataAdapter adapObj=new SqlAdapter("Select * from student ",conObj);
    
    DataTable dtObj=new DataTable();
    
    adapObj.fill(dtObj);
    
    dataGridView.DataSource=dtObj;
    

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: