Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Star
10672 Points
2426 Posts
May 02, 2012 09:25 AM|LINK
This is the basic method to use DataReader
con = new SqlConnection(ConfigurationManager.ConnectionStrings["YourString"].ConnectionString); con.Open(); string str = "SELECT Field1.Field2. field3 FROM table"; SqlCommand cmd = new SqlCommand(str, con); SllDataReader dr = cmd.ExecuteReader(); dr.Read(); YouRGridView.DataSource = dr; YourGridView,DataBind(); con.Close();
To get a field from reader,
If it is a string value in fiirst column it can be obtained as
dr.GetString(0)
basheerkal
Star
10672 Points
2426 Posts
Re: Retrieving Values from DataReader
May 02, 2012 09:25 AM|LINK
This is the basic method to use DataReader
con = new SqlConnection(ConfigurationManager.ConnectionStrings["YourString"].ConnectionString); con.Open(); string str = "SELECT Field1.Field2. field3 FROM table"; SqlCommand cmd = new SqlCommand(str, con); SllDataReader dr = cmd.ExecuteReader(); dr.Read(); YouRGridView.DataSource = dr; YourGridView,DataBind(); con.Close();To get a field from reader,
If it is a string value in fiirst column it can be obtained as
dr.GetString(0)
(Talk less..Work more)