943,955 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 9198
  • ASP.NET RSS
Nov 20th, 2006
-1

how to show data from database in label?

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yanti is offline Offline
4 posts
since Nov 2006
Jan 1st, 2009
0

Re: how to show data from database in label?

how about if i want to show all data from database in dynamic label array?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
beryls is offline Offline
2 posts
since Dec 2008
Jan 1st, 2009
0

Re: how to show data from database in label?

sorry i am posting in the wrong thread..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
beryls is offline Offline
2 posts
since Dec 2008
Jan 1st, 2009
0

Re: how to show data from database in label?

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()
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Jan 1st, 2009
0

Re: how to show data from database in label?

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.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Only post time
Next Thread in ASP.NET Forum Timeline: How to create a pm alert notice





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC