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 are the new thee features of com+ services, which are not there in com (mts)?

0 Answers  


what is the use of stored procedure which has only one select statement over simple select statment query ? Why to write a stored procedure then ?

3 Answers  


What are the new 2.0 features useful for?

0 Answers  


What is the difference between a Hash Table and a Dictionary?

1 Answers  


Write a program to create a user control with name and surname as data members and login as method and also the code to call it.

0 Answers  






Is it possible implement webservices without SOAP?

2 Answers   HCL,


What is RCW (Run time Callable Wrappers)?

0 Answers  


How to get the hostname or IP address of the server?

2 Answers  


in hibernate, what is dirty reading?

1 Answers   IBM,


What is a .DLL and .EXE files called in .NET?

0 Answers   CitiusTech,


Compare & contrast rich client (smart clients or windows-based) & browser-based web application

0 Answers  


What is the difference between Dataset and DataReader? Can u breif me ADO.net classes and architecture

2 Answers   Deloitte,


Categories