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

What is http response header?

0 Answers  


What is machine.config and web.config ?

5 Answers   Digital GlobalSoft,


How is application management and maintenance improved in asp.net 2.0?

0 Answers  


How do you define authentication in Web.Config?

2 Answers   Patni,


What are the various types of validation controls provided by asp.net?

0 Answers  


What is CLS?

5 Answers   IBM, PrimeLine, TCS,


How to integrate angular 8 with asp.net mvc 5? : Asp.Net MVC

0 Answers  


Which institute provide good Project training on .Net technologies in hyd?

5 Answers  


is it possible to use web site without web server from remote place?

1 Answers   ABC, Mannar Company, Quadrant,


Write the different features of a Thread and a Process?

0 Answers   Siebel,


What New Features comes with ASP.NET Web API 2.0?

0 Answers  


Is asp net front end or backend?

0 Answers  


Categories