how to show data from database in label?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 4
Reputation: yanti is an unknown quantity at this point 
Solved Threads: 0
yanti yanti is offline Offline
Newbie Poster

how to show data from database in label?

 
0
  #1
Nov 20th, 2006
here the code i've try....but still not working....please help me..
<page_load>
id = 6
dbconn = New SqlClient.SqlConnection("workstation id=HOME-5F227C8500;packet size=4096;user id=sa;initial catalog=pubs;persist security info=False")
dbconn.Open()
sql = "select * from NEWS Where NewsID='" & id & "'"
dbcomm = New SqlClient.SqlCommand(sql, dbconn)
Try
dbread = dbcomm.ExecuteReader(CommandBehavior.CloseConnection)
While dbread.Read()
lbl1.Text = dbread("NewsID")
lblModel.Text = dbread("NewsModel")
lblPrice.Text = dbread("NewsPrice")
lblDescription.Text = dbread("NewsDescription")
Image5.ImageUrl = (dbread("NewsPic"))
Image5.DataBind()
Image5.ToolTip = (dbread("NewsModel"))
End While
dbread.Close()
dbconn.Close()
Catch ex As Exception
End Try
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: beryls is an unknown quantity at this point 
Solved Threads: 0
beryls beryls is offline Offline
Newbie Poster

Re: how to show data from database in label?

 
0
  #2
Jan 1st, 2009
how about if i want to show all data from database in dynamic label array?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: beryls is an unknown quantity at this point 
Solved Threads: 0
beryls beryls is offline Offline
Newbie Poster

Re: how to show data from database in label?

 
0
  #3
Jan 1st, 2009
sorry i am posting in the wrong thread..
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: how to show data from database in label?

 
0
  #4
Jan 1st, 2009
Try this:

lbl1.Text = dbread("NewsID").ToString()
lblModel.Text = dbread("NewsModel").ToString()
lblPrice.Text = dbread("NewsPrice").ToString()
lblDescription.Text = dbread("NewsDescription").ToString()
Image5.ImageUrl = (dbread("NewsPic")).ToString()
Image5.DataBind()
Image5.ToolTip = (dbread("NewsModel")).ToString()
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: how to show data from database in label?

 
0
  #5
Jan 1st, 2009
Your method should be working alright.. Are you sure you are returning a row from the database? You might not be finding anything. Run it manually to see your result.
I answer pm's.
I answer questions.
I answer quickly.
I answer.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC