syntax for binding the data from database



syntax for binding the data from database..

Answer / sambhu sankar biswal

Actually There is no syntax to bind data from data base.

to bind data from data base
1st step:-create connection to database
2nd step:-write command
3rd step:-create object of data adapter(oledb/sql)
4th step:-create object of dataset
5th step:-dataadapter's object name.fill(dataset's object name);
6th step:-control name(where u have to bind the
data).DataSource=dataset's object name;
7th step:-control name(where u have to bind the
data).DataBind();



Example:-suppose we need to bind data from "emp" table to
gridview control


Code is bellow:-

Using system.Data.Oledb;//Name space

//inside page load event

OledbConnectionn cn=new
OledbConnection("provider=microsoft.jet.oledb.4.0;data
source=c:/db2.mdb");//complete path of the data base.
OledbCommand cmd=new OledbCommand("select * from emp",cn);
OledbDataAdapter da=new OledbDataAdapter(cmd);
DataSet ds= new DataSet();
da.fill(ds);
GridView1.DataSource=ds;
GridView1.DataBind();

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More Dot Net General Interview Questions

What is strong-typing versus weak-typing? Which is preferred?

0 Answers  


What is file extension of Webservices in .Net?

0 Answers   Arigo Infotech,


SAP Business One(this is intigrated tool of .net)

0 Answers   TCS,


What is func in .net 3.5?

0 Answers  


What is connection pooling and how do you make your application use it?

0 Answers  






How is meant by dll in .net?

0 Answers  


Explain what is mutex?

0 Answers  


Can you write a class without specifying namespace?

0 Answers  


Is .net front end or backend?

0 Answers  


How you apply a theme in whole application in .Net?

0 Answers   PUCIT,


What is shared and repeatable inheritance?

0 Answers  


Explain me what is the .net framework and how does it work?

0 Answers  


Categories