View Single Post
 
Old March 3rd, 2009, 02:28 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Thanks , can i ask u something?
i have 6 lablels that i need to bind, i am a bit wored about performance if i have to open 6 connections and close them that is not something i want to do, is there a way to do this under one connection? or use deferent controls that can do this in a lighter weight?

My table has 6 columns and 1 row i want to bind each column into labels/asp:conntrols

can i do it like this:
Code:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionString("Minds").ConnectionString);
SqlCommand cmdd = newSqlCommand("Select HomeLeft, Right, Centre from Home");
SqlDataReader dr = null;
cmdd.Connection = con;
con.Open();
dr = cmdd.ExecuteReader();
dr.Read();
if (dr.HasRows == true)
{

label1.Text = dr.GetString(dr.GetOrdinal("HomeLeft"));
label2.Text = dr.GetString(dr.GetOrdinal("Right"));
label3.Text = dr.GetString(dr.GetOrdinal("Centre"));.....
thanks
__________________
bx