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 different authentication mechanisms used in ASP.NET?

0 Answers   Amdocs,


Define repository pattern in mvc.net? : asp.net mvc

0 Answers  


What does asax stand for?

0 Answers  


I have an excel file with data, i am importing this excel file data into Sqlserver 2005 database. while importing i am getting wrong data(ie, special characters) in one column(description column), upto some limit the data in that column is coming fine,after that data is coming like below. The "Walter" leather storage bench is one of our most popular styles. The top with the tufting and double stitching finish a very impressive piece. The size is perfect in front of beds and the storage adds another functional bonus. Open it up and sneak al���Ƴ�Â��ƴ�Ã��ƶ�Å�� al���Ƴ�Â��ƴ�Ã��ƶ�Å�� Is there anywhy to resolve this? (I am using recordset in coding for developing import process.) please help me soon.

0 Answers  


How to use a Master Database in Asp.net?

0 Answers   MCN Solutions,






Describe the difference between inline and code behind - which is best in a?

0 Answers  


What r the asp.net list controls and diff. Between them?

0 Answers  


What is server infrastructure & server components?

0 Answers  


What is http only cookie?

0 Answers  


Which method do you use to enforce garbage collection in .net?

0 Answers  


What are strong names?

0 Answers  


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

0 Answers  


Categories