ADO.Net - how to get data from database and bind to the
controls -- write this small code

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we apply themes to an asp.net application?

562


What is application variable in asp.net?

468


What is the difference between typeof() vs gettype()?

556


What is difference between URL and URI?

632


Explain the updatepanel?

586






What are the advantages of the code-behind feature?

544


Which is faster viewdata or viewbag?

545


If you are using two select queries and retrieving data. how do you access second query's result set using data reader?

4756


If we remove web.config or machine.config from the application then, is this application will works?

600


Asp pages that worked pefectly on windows 2000 server and iis 5.0 do not work on windows 2003 server with iis 6.0. Asp.net pages work fine. Why?

561


List the types of authentication supported by asp.net?

528


What is marshalling ? Is it a part of asp.net ?

615


What are the different types of validation controls provided in ASP.NET?

670


What is the difference between ldap and active directory?

517


Why mvc is better than asp.net? : Asp.Net MVC

473