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
Using activex control in .net?
What are the difference bbetween value type & reference types ? Example from .net. Integer & struct are value types or reference types in .net?
How to create properties and methods using controls?
In code behind class, name the type of code found. Is it the server side code or client side code?
What is the base class of Button control in .NET?
Define satelite assembly?
How will you make .NET programs work in Linux ?
Explain what is the reason of occurring overflow-underflow arithmetic exception error, it shows error message when we run our program by adding control?
How can you instantiate a tuple?
What is .net and why it is used?
What are an object and a class?
What is new in .net core?
What is the benefit of .net core?
Explain soap and xml?
explain the states of a window service application?