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 |
What is static constructor, when it will be fired? And what is its use?
How do you pass value of a text box from page1.aspx to page2.aspx without storing it as a session value?
Explain the difference between static page and dynamic page?
What is dot net and its uses?
What are the differences between com architecture and.net architecture?
What's typical about a windows process in regards to memory allocation in .net?
What are the drawbacks for Model-View-Controller Architecture?
What is meant by .Net framework?
What are channels in .NET Remoting?
What is MSIL, IL, CTS?
Where does the gac exist ?
What is UDDI and how to register a web service ?