//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.Open()
cmd.Connection = cn
cmd.CommandText = "SELECT DISTINCT name as 'named' FROM master"
dr = cmd.ExecuteReader()
While dr.Read
DropDownList1.Items.Add(dr.Item("named"))
End While
cn.Close()
end if
No comments:
Post a Comment