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

If you want to bind the columns manually within the asp:datagrid tags what kind of tags you have to add.

0 Answers   Siebel,


Does asp.net still recognize the global.asa file?

0 Answers  


Explain server control extensibility with reference to asp.net 2.0 ?

0 Answers  


Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process?

1 Answers   Patni, Perot Systems, Sedna Technology,


Differences between session state and Application state?

6 Answers  






1.can we add connection string in global.asax?????????? 2.what are the default files included when we create new web application????

7 Answers   Sparsh,


How can you debug your.net application?

0 Answers  


Tell About Web.config ?

2 Answers   Keane India Ltd,


Apart from IDE what are the enhancements in asp.net 2.0?

0 Answers   Microsoft,


when u enter the data in one text box once u completed entering the text box data then one page has to be popuped and the text has to be displayed in the parent page

1 Answers  


If there is submit button in a from tell us the sequence what happens if submit is clicked and in form action is specified as some other page ?

1 Answers   MMTS,


Difference between overriding and overloading?

0 Answers  


Categories