here the code i've try....but still not working....please help me..
id = 6
dbconn = New SqlClient.SqlConnection("workstation id=HOME-5F227C8500;packet size=4096;user id=sa;initial catalog=pubs;persist security info=False")
sql = "select * from NEWS Where NewsID='" & id & "'"
dbcomm = New SqlClient.SqlCommand(sql, dbconn)
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.ToolTip = (dbread("NewsModel"))
End While
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.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.