DataSet
(1 DS can have Multiple DT)
-Dataset objds=new DataSet();
-objds.Table[0|1];
-SqlDataAdapter objda=new SqlDataAdapter("select * from employee");
-objda.Fill(objds, " employee");
-dg.DataSource=objds;
-dg.DataMember="employee";
-dg.DataBind();
Back |
DataTable
-DataTable objdt=new
DataTable("tbname");
Primary Key Column
DataColumn[] PKColumn=new
DataColumn[1]; /* define pk column array*/
DataColumn objdc=new
DataColumn("ID",typeof(int)); /* define first column
with ID 's type INT */
objdt.Columns.Add(objdc); /* Add
column to datatable's column collection */
PKColumn[0]=objdc;
/* assign ID column to primary key array*/
b.PrimaryKey=PKColumn;
/* set table's PK to primary key array */
objdc.AutoIncrement=true;
objdc.AutoIncrementSeed=1;
objdc.AutoIncrementStep=1;
_____________________________________
Regular column
objdt.Columns.Add("LastName",
typeof(string));
Back |
DataColumn
-DataColumn objdc=new DataColumn("colname " , Type.GetType("System.DataType)
*DataType : Int, Char, String, Decimal, Double, DateTime
-Datacolumn []pk=new Datacolumn[1] //define array[1]
-pk[0]=objdc
-objdt.PrimaryKey=pk;
-objdc.Properties
*objdc.AutoIncrement =true;
*objdc.AutoIncrementSeed=2;
*objdc.AutoIncrementStep=2;
*objdc.Unique=true;.
*objdc.DefaultValue=1;
*objdc.MaxLength=25;
*objdc.ReadOnly=true;
*objdc.DataType=int,char..
Back
|
DataRow ( no need to
create instance of datarow using NEW)
DataRow objdr=objdt.NewRow(); or objds.Tables[0].NewRow();
objdr["FirstName"]=txtfn.Text;
objdr["LastName"]=txtln.Text;
objdt.Rows.Add(objdr);
Session["Insurance"]=objdt;
dg.DataSource=Session["Insurance"];
Back |
DataView ( return
DV as Icollection)
-It has Sort and RowFilter properties
eg.
objdv.Sort=" city" ;
objdv.FilterRow=" City='memphis' ";
DataView objdv=new DataView();
objdv=objdt[0].DefaultView; or objdv=new
DataView(objdt);
Back
|
DataRelation
-establish relationship between two datatables.
eg
DataRelation rl= new DataRelation();
rl=ds.Relations.Add("relation_name" , ds.Tables["customer"].Columns["CID"]
, ds.Tables["order"].Columns["CID"] );
Back |
Access Data of DataRow and DataView
objds.Tables[0].Rows[0][3] ; /* 1st row ,3rd column
*/
objdv["ID"]["City"];
Back |