Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
All

All

Ratings: (0)|Views: 2 |Likes:
Published by Navi Bharat
ADO.Net various topics
ADO.Net various topics

More info:

Published by: Navi Bharat on Apr 21, 2014
Copyright:Traditional Copyright: All rights reserved

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

04/21/2014

pdf

text

original

 
DataAdapter Class
Represents a set of SQL commands and a database connection that are used to fill the DataSet and update the data source.
 
The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet.  If you are connecting to a SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand andSqlConnection objects. For OLE DB-supported data sources, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects. For ODBC-supported data sources, use the DataAdapter with its associated OdbcCommand and OdbcConnection objects. For Oracle databases, use the DataAdapter with its associatedOracleCommand and OracleConnection objects. When an instance of DataAdapter is created, the read/write properties are set to initial values. For a list of these values, see the DataAdapter constructor.
DataTable Class
Represents one table of in-memory data. The DataTable is a central object in the ADO.NET library. Other objects that use the DataTable include the DataSet and the DataView.  When accessing DataTable objects, note that they are conditionally case sensitive. For example, if one DataTable is named "mydatatable" and another is named "Mydatatable", a string used to search for one of the tables is regarded as case sensitive. However, if "mydatatable" exists and "Mydatatable" does not, the search string is regarded as case insensitive. A DataSet can contain two DataTable objects that have the same TableName property value but different Namespace property values. For more information about working with DataTable objects, see Creating a DataTable (ADO.NET).  If you are creating a DataTable programmatically, you must first define its schema by adding DataColumn objects to the DataColumnCollection (accessed through theColumns property). For more information about adding DataColumn objects, see Adding Columns to a DataTable (ADO.NET).  To add rows to a DataTable, you must first use the NewRow method to return a new DataRow object. The NewRow method returns a row with the schema of the DataTable, as it is defined by the table's DataColumnCollection. The maximum number of rows that a DataTable can store is 16,777,216. For more information, see Adding Data to a DataTable.  The DataTable also contains a collection of  Constraint objects that can be used to ensure the integrity of the data. For more information, see DataTable Constraints (ADO.NET).  There are many DataTable events that can be used to determine when changes are made to a table. These include RowChanged, RowChanging, RowDeleting, andRowDeleted. For more information about the events that can be used with a DataTable, see Handling DataTable Events (ADO.NET).  When an instance of DataTable is created, some of the read/write properties are set to initial values. For a list of these values, see the DataTable.DataTable constructor topic.
 
The following example creates two DataTable objects and one DataRelation object, and adds the new objects to a DataSet. The tables are then displayed in a DataGridViewcontrol. C#
// Put the next line into the Declarations section. private System.Data.DataSet dataSet; private void MakeDataTables() { // Run all of the functions. MakeParentTable(); MakeChildTable(); MakeDataRelation(); BindToDataGrid(); } private void MakeParentTable() { // Create a new DataTable. System.Data.DataTable table = new DataTable("ParentTable"); // Declare variables for DataColumn and DataRow objects. DataColumn column; DataRow row; // Create new DataColumn, set DataType, // ColumnName and add to DataTable. column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "id"; column.ReadOnly = true; column.Unique = true; // Add the Column to the DataColumnCollection. table.Columns.Add(column); // Create second column. column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "ParentItem"; column.AutoIncrement = false; column.Caption = "ParentItem"; column.ReadOnly = false; column.Unique = false; // Add the column to the table. table.Columns.Add(column); // Make the ID column the primary key column. DataColumn[] PrimaryKeyColumns = new DataColumn[1]; PrimaryKeyColumns[0] = table.Columns["id"]; table.PrimaryKey = PrimaryKeyColumns;
 
 // Instantiate the DataSet variable. dataSet = new DataSet(); // Add the new DataTable to the DataSet. dataSet.Tables.Add(table); // Create three new DataRow objects and add // them to the DataTable for (int i = 0; i<= 2; i++) { row = table.NewRow(); row["id"] = i; row["ParentItem"] = "ParentItem " + i; table.Rows.Add(row); } } private void MakeChildTable() { // Create a new DataTable. DataTable table = new DataTable("childTable"); DataColumn column; DataRow row; // Create first column and add to the DataTable. column = new DataColumn(); column.DataType= System.Type.GetType("System.Int32"); column.ColumnName = "ChildID"; column.AutoIncrement = true; column.Caption = "ID"; column.ReadOnly = true; column.Unique = true; // Add the column to the DataColumnCollection. table.Columns.Add(column); // Create second column. column = new DataColumn(); column.DataType= System.Type.GetType("System.String"); column.ColumnName = "ChildItem"; column.AutoIncrement = false; column.Caption = "ChildItem"; column.ReadOnly = false; column.Unique = false; table.Columns.Add(column); // Create third column. column = new DataColumn(); column.DataType= System.Type.GetType("System.Int32"); column.ColumnName = "ParentID"; column.AutoIncrement = false; column.Caption = "ParentID";

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->