The Listbox control can be bound to a single column via a DataReader in an
ASP.NET program, but not directly to the ListBox control in a Windows forms
application. That would take using code (something) like this
Private Sub BuildCommand()
Try
cmd = New SqlCommand("SELECT Au_ID, Author, Year_Born FROM
Authors " _
& " WHERE Year_Born = @YearWanted", cn)
cmd.Parameters.Add("@YearWanted", SqlDbType.Int).Value = 1947
cn.Open()
Dim dr As SqlDataReader
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim tb As New DataTable
tb.Load(dr)
ListBox1.DisplayMember = "Author"
ListBox1.DataSource = tb
Catch exsql As SqlException
MessageBox.Show(exsql.ToString)
Catch ex As Exception
Debug.Assert(False, ex.ToString)
Finally
cn.Close()
End Try
End Sub
--
FMI see my 7th Edition.
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________