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 will you register com+ services?
What are the collections you've used?
What is "common language specification" (cls) in .net?
Tell me what is serialization?
What is the advantage of .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.
Is .net core free?
Can you write a class without specifying namespace?
Please tell us what is the difference between override and overload in a method?
Types of evidence in .net with context to CAS
What is managed code execution?
As you know read-only variables and constants have many similarities, but what is at least one way that they differ?
Is there built-in support for tracing?
What is multiThreading in .NET?
How many types of design patterns available in .NET?