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 initiate validation on the server manually? What are two situations when you might you want to do that?

0 Answers  


What is a WebService and what is the underlying protocol used in it? Namespace?

1 Answers  


Is asp.net web forms dead?

0 Answers  


What are the difference between ASP and ASP.Net?

4 Answers   Accenture, Mphasis,


What is data cache in sql server?

0 Answers  






Explain what does wsdl stand for?

0 Answers  


What is deference between asp.net, vb.net, c# & j#

2 Answers  


What is difference between viewstate and session in asp net?

0 Answers  


under which namespaces connection strings can be defined?

4 Answers  


benefits of migration from asp to asp.net hi frnds, i have to give presentation to a client about how useful would be migrating their project from asp to asp.net .plz give me some points which i should incorporate in my ppt thanks

0 Answers  


The technical part was on ASP.Net only of web services.

1 Answers   Symphony,


By default what is the Asp.Net application login context on IIS 5.0? By default the ASP.Net app runs in the context of a local user ASPNet on IIS version 5. On IIS version 6 on windows 2003 it is called Network service

0 Answers  


Categories