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
How to spawn a thread?
Describe the use of following com+ services jit activation, queued components, object pooling.?
What are code contracts?
Explain me what is an anonymous method and how is it different from a lambda expression?
Example from .net. Integer & struct are value types or reference types in .net?
What is a web service in .net?
Can you edit data in repeater control? How?
How do you define the lease of the object in .net?
I was working for software company frm 2005 to 2009. I left job due to recession.I was jobless till dec 09 then i got job in bpo and i am not knowing what to do as my professional experience is with software.give me any suggestion.
What are Attributes in .NET?
Can you write a class without specifying namespace?
One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid this problem?
What is reflection and what is it for?
Is .net core stable?
What is the transport protocol you use to call a seb service soap?