Loading Database data into Labels for viewing?

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 3
Reputation: rubentan is an unknown quantity at this point 
Solved Threads: 0
rubentan rubentan is offline Offline
Newbie Poster

Loading Database data into Labels for viewing?

 
0
  #1
Nov 1st, 2008
Is it possible to load database data into labels for viewing?
i already know the query to return the data i want to show but i dont know how to put it into a label.. anyone got any ideas? i tried searching but so far i have nothing.. :c
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Loading Database data into Labels for viewing?

 
0
  #2
Nov 1st, 2008
Work through the returned data setting the appropriate labels
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: rubentan is an unknown quantity at this point 
Solved Threads: 0
rubentan rubentan is offline Offline
Newbie Poster

Re: Loading Database data into Labels for viewing?

 
0
  #3
Nov 1st, 2008
im sorry im kinda new at this, can you expand? thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: Loading Database data into Labels for viewing?

 
0
  #4
Nov 2nd, 2008
I don't know whitch kind of data base you use but any way. Fill a dataset object with data using Data Adapter as normally
then

you can get the cell value of a given data table as follow and set it to the textbox.text

textBox.Text = dataset.tables[0].rows[ row index here][cell index here];
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 32
Reputation: reena12 is an unknown quantity at this point 
Solved Threads: 4
reena12 reena12 is offline Offline
Light Poster

Re: Loading Database data into Labels for viewing?

 
0
  #5
Nov 3rd, 2008
Hi

SqlConnection ObjConn = new SqlConnection(ConnectionString);

if (ObjConn.State != ConnectionState.Open)
{
ObjConn.Open();
}

SqlDataAdapter ObjSqlDataAdapter = new SqlDataAdapter(CommandText, ObjConn);

Ds = new DataSet();
ObjSqlDataAdapter.Fill(Ds);

if (ObjDs.Tables[0].Rows.Count > 0)
{
label1.Text = ObjDs.Tables[0].Rows[rowindex][columnname].toString();
-
-
}

ObjDs.Dispose();
ObjConn.Close();
ObjConn.Dispose();
Reena Mehta

Remember to click on Mark as answer on the post that helped

http://www.indianic.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 898 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC