ADO.Net - how to get data from database and bind to the
controls -- write this small code

Answers were Sorted based on User's Feedback



ADO.Net - how to get data from database and bind to the controls -- write this small code..

Answer / alb.shah

Creating a Database Connection at Run Time
Create the data connection object.
Create a data adapter object.
Create a data set object.
Invoke methods on the adapter object to fill or update the
data set.
Use data binding or another technique to display the data
from the data set.

Is This Answer Correct ?    5 Yes 0 No

ADO.Net - how to get data from database and bind to the controls -- write this small code..

Answer / kaarthikeyan

establish a connection and declare sqldataadapter,dataset
sda=new sqldataadapter("select the appropriate
table",connectionobj);
ds=new dataset();
sda.fill(ds);
gridview1.datasource=ds;
gridview1.databind();

Is This Answer Correct ?    3 Yes 0 No

ADO.Net - how to get data from database and bind to the controls -- write this small code..

Answer / kinjal panchal

first of all write namespace in your page.
using Syste.data.sqlclient;

//code
sqlconnection cn=new sqlconnection();
cn.open();
sqlcommand cmm=new sqlcommand("write select query here",cn);
sqldataAdupter da=new sqldataAdupter(cmm);
datatable dt=new datatable();
da.fill(dt);
cn.close();

suppose u have gridview control then

gridview.datasource=dt;
gridview.databind();

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

How do you declare delegates and are delegates and events one and the same and explain how do you declare delegates and invoke them ?

1 Answers   MMTS,


Explain different authentication modes in asp.net?

0 Answers  


Features in ASP.NET?

2 Answers   Microsoft,


What is the procedure to create the environment for asp.net? : asp.net mvc

0 Answers  


What is autopostback in asp net?

0 Answers  






What is http session state?

0 Answers  


Explain what does mvc represent in asp.net? : asp.net mvc

0 Answers  


what is CLR?

3 Answers   PrimeLine,


If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) In my application?

0 Answers  


Explain the difference between page.registerclientscriptblock and page.registerstartupscript?

0 Answers  


Why we use dbms for projects? Why don’t we save any application data in separate files instead of dbms?

0 Answers  


What is Http handler?

5 Answers   Accenture,


Categories