.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

fill DataTable with DataReader usign ADO.NET

Posted By:Syed Shakeer Hussain       Posted Date: June 27, 2010    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  

fill DataTable with DataReader

The follwoing Code explains you how to fill DataTable with DataReader and dispaly the data in DropDownList Control.

using System.Data;

using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page


OleDbConnection conn_MSACCESS = new OleDbConnection(ConfigurationManager.ConnectionStrings["MS-db1ConnectionString"].ConnectionString);

protected void Page_Load(object sender, EventArgs e)



DataTable dtable = new DataTable();

dtable = fillddl();

DropDownList1.DataSource = dtable;

DropDownList1.DataTextField = "productname";

DropDownList1.DataValueField = "productid";




 public DataTable fillddl()


DataTable dt = new DataTable();

OleDbCommand cmd = new OleDbCommand("Select * from vendortbl", conn_MSACCESS);

OleDbDataReader reader = cmd.ExecuteReader();


return dt;




Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend