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 use css in asp.net?

8 Answers   iBridge,


What is the difference between ASP Session State and ASP.Net Session State?

0 Answers  


How can you register a custom server control to a web page?

0 Answers  


How do I send an email message from my ASP.NET page?

0 Answers  


What does WSDL stand for?

10 Answers   Siebel Systems,


In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?

0 Answers   HCL,


on modify statement, executeNonQuery returns zero rows affected even though there has been modification carried out sucessfully in the table.. can anyone tell me is this possible??? if yes, how..???

1 Answers   ADITI,


AJAX - explain the concept and some controls like update panel, tabcontrol etc

2 Answers   Syntel,


What is the syntax for datagrid and specifying columns?

0 Answers   Microsoft, SF,


How to Deploy a project?

2 Answers  


How we implement web farm and web garden concept in asp.net?

0 Answers  


What are the namespaces used in asp.net mvc? : asp.net mvc

0 Answers  


Categories