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
Can you write a class without specifying namespace?
What is the difference between asp.net & vb.net and explain architecture?
What is the purpose of enumerable class in .net?
How can I find out what the garbage collector is doing?
What is your observations between vb.net and vc#.net?
Tell us what is a sealed class?
How do you generate a strong name?
Should I use readerwriterlock instead of monitor.enter/exit?
Will my .net app run on 64-bit windows?
Tell me about secure socket layer? How to make use of the technology?
How to prepare parametrized (with more than one parameters) crystal report.pls tell me the code procedure, if any body can?
Explain the .net framework overview?
What is a web service in .net?
Why do we use msmq?
What's singleton activation mode in .net?