0
我要显示在一个组合框在一个特定的列中的所有数据和我的代码只是显示在这里列的最后一个数据的SQL coulmn数据是我使用显示在vb.net组合框
代码Dim connectionstring As String = "Data Source=localhost\SQLEXPRESS;InitialCatalog=Enginee;Integrated Security=True"
Try
Dim connection As New SqlClient.SqlConnection(ConnectionString)
Dim sqlquery As String
connection.Open()
MessageBox.Show("Open")
sqlquery = " Select PROJECT.PROJECT_CODE,PROJECT.PROJECT_NAME From PROJECT INNER JOIN ENGINEERS on ENGINEERS.ENGINEER_ID = ENGINEERS.ENGINEER_ID where ENGINEERS.FNAME = '" & Sign_In.TextBox1.Text & "' "
Dim selectcommand As New SqlClient.SqlCommand(sqlquery, connection)
Dim reader As SqlClient.SqlDataReader = selectcommand.ExecuteReader
Dim test As Boolean = reader.Read
While test = True
ComboBox1.Text = reader(0)
TextBox1.Text = reader(1)
test = reader.Read
End While
Catch ex As Exception
MessageBox.Show("Failed")
End Try
使用此ComboBox1.Items.Add(reader(0).ToString())而不是ComboBox1.Text。 – MMK