Home > Deveploment and Programming > How to Create Untype dataSet and add value

How to Create Untype dataSet and add value

Steps.
1.
Create a one DataTable at least, then associate columns in the table, then associate row in a table
 
 

DataTable dt =new DataTable () ; //new table

dt.Columns.Add (

new DataColumn ("Name",Type.GetType("System.String")));

dt.Columns.Add (

new DataColumn ("Code",Type.GetType("System.String")));

dt.Columns.Add (new DataColumn ("Contact",Type.GetType("System.String")));

DataRow dr;

dr=dt.NewRow();

dr["Name"]="Sanjiv Kumar";

dr["Code"]="127";

dr["Contact"]="123456";

dt.Rows.Add(dr);

dr=dt.NewRow();

dr["Name"]="Sunil";

dr["Code"]="123";

dr["Contact"]="123456";

dt.Rows.Add(dr);

2. Associate this table into Dataset.

DataSet ds=new DataSet();

ds.Tables.Add(dt);

3.Show into DataGrid

dataGrid1.DataSource=ds.Tables[0];

4.To retrive value from dataset

 string name=ds.Tables[0].Rows[0][0];

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: