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

how about if i want to show all data from database in dynamic label array?

sorry i am posting in the wrong thread.. :|

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()

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.