Adding to Listview

tehon3299

Well-known member
Joined
Jan 6, 2003
Messages
155
Location
Liverpool, NY
I need to get all the items under a certain column in SQL and add them all to a Listview. How would I do this?

I know how to connect to SQL and add things to listviews but I dont know how to add them when its from SQL.
 
The method depends on the ADO.NET code youre using. Well need to see whether youre using a DataSet or a DataReader, among various other options.
 
This is the code I am using:
Code:
        Dim MyCommand As New SqlCommand()
        Dim MyConnection As New SqlConnection()
        Dim MySQLDataAdapter As New SqlDataAdapter()
        Dim SessionCmd As String

        MyConnection = New SqlConnection("server=(local);database=StatKeeper;Trusted_Connection=yes")

        SessionCmd = "Select (TeamName) FROM tmTeams"

        MyCommand = New SqlCommand(SessionCmd, MyConnection)

        MyCommand.Connection.Open()

        Try
            MyCommand.ExecuteNonQuery()
        Catch Exp As SqlException
            If Exp.Number = 2627 Then

            Else

            End If
        End Try

        MyCommand.Connection.Close()
 
Back
Top