Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to retrieve data from database to gridview with connected architecture in c# window appliaction using ado.net
Posted

You can use datareader to for connected architecture

SqlCommand cm = new SqlCommand("Select * from table1", con);
SqlDataReader dr;
dr = cm.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(dr);

in case of winform
dataGridView1.DataSource = dataTable;

in case of webform
GridView1.DataSource = dataTable;
GridView1.databind();
 
Share this answer
 
v2
Comments
Wendelius 11-Apr-11 12:17pm    
Pre tags added
using this:-
sqlconnection con=new sqlconnetion(connection string);
sqldataadapter adapter=new sqldatadpter(select command);
dataset ds=new dataset();
gridview1.DataSource=ds.Tables[0];

//but above is disconnected mode.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900