Friday, August 27, 2010

VB.NET : Fill DropDownList With a Column Values From The Table

//When Connection string present in web.config file

If Not IsPostBack Then

Dim cn As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader

cn = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
cmd.Connection = cn
cmd.CommandText = "SELECT DISTINCT name as 'named' FROM master"
dr = cmd.ExecuteReader()
While dr.Read
End While

end if

No comments: