Wednesday, February 22, 2012

Read & Display SQL data into Label

Code:

Dim conn As New SqlConnection
(ConfigurationManager.ConnectionStrings("SqlServerExecSP").ToString())
conn.Open()
Dim sql As String = "Select Name from People where Id = 1"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Dim rd As SqlDataReader = cmd.ExecuteReader()

While rd.Read()
label1.Text = rd("Name")
End While


Change the connection string and table name in the above code.

Happy Programming!!

No comments:

Post a Comment

Highly Appreciated your comments