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 Assembly manifest? what all details the assembly manifest will contain.

1 Answers  


What is IIS and how we deploy website on IIS.

2 Answers   NetLink,


Which two properties are on every validation control?

7 Answers   Siebel Systems,


Explain what do the terms “boxing” and “unboxing” mean?

0 Answers  


What are the differences in C# .Net and ASP .Net.

4 Answers   NetLink,






Explain webfarm vs webgardens in .net?

0 Answers  


Is do-it (chennai) a good institute to learn dot-net???? are the trainers well experienced??

2 Answers   Satyam,


What is the difference between task and thread in .net?

0 Answers  


Is there any thread in our .net programs?

0 Answers  


What is the difference between boxing and unboxing?

0 Answers  


How does the generational garbage collector in the .net clr manage object lifetime? What is non-deterministic finalization?

0 Answers  


In code behind class, name the type of code found. Is it the server side code or client side code?

0 Answers   Accenture,


Categories