0

色の列に値のリストを表示しようとしていますが、ボタンをクリックすると値が 1 つしか表示されません

Imports System.Data
Imports System.Data.OleDb

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ''TODO: This line of code loads data into the '''AdventureWorksLTDataSet.Product' table. You can move, or remove it, as needed.
        Me.ProductTableAdapter.Fill(Me.AdventureWorksLTDataSet.Product)

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim conDB As New OleDb.OleDbConnection
        conDB.ConnectionString = "....."
        Dim comDB As New OleDb.OleDbCommand
        Dim dbrDB As OleDbDataReader
        Dim SQLQuery As String

        conDB.Open()
        comDB.Connection = conDB
        SQLQuery = "SELECT DISTINCT P.color FROM SalesLT.Product P WHERE P.color is not NULL"
        comDB.CommandText = SQLQuery
        dbrDB = comDB.ExecuteReader()



        If (dbrDB.Read) Then
            While dbrDB.Read       ' 'cycle through resulting tuples
                Label1.Text = dbrDB("color")
            End While
        End If



    End Sub
End Class
4

1 に答える 1

4

ループするたびにラベルの値を上書きしています。これが必要な場合があります。

Label1.Text = Label1.Text + "," + dbrDB("color")
于 2013-03-19T01:27:57.573 に答える