Answer Posted / 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 View All Answers
What are three common acronyms used in .net, and what do they stand for?
Explain what is reflection in microsoft .net context?
what will do to avoid prior case?
What should you do to store an object in a viewstate?
What is the difference between web application and enterprise application?
What are the differences between user control and server control?
Can you edit data in repeater control? How?
hai, about trading domain and need simple project on trading system. please help me...
What tools can I use to develop .net applications?
Explain the difference between garbage collections in .net 4.0 and earlier versions?
Please explain what is heap and what is stack?
What does il do?
Explain Creational design pattern in .NET?
What are the purposes of using .net?
How to implement datagrid in.net? How would you make a combo-box appear in one column of a datagrid? What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for datagrid methods. What is the access specifier used for that methods in the code behind file and why?