我有一个名为services的表,其中存储了所有正畸服务。以下是存储在服务表中的数据列表:

Extract
Cleaning
Jacket
Upper teeth braces
lower teeth braces
upper and lower teeth braces


我希望这些服务存储在cmbBraces中。但是,它随后显示了所有服务:我只希望在cmbBracesUpper teeth braceslower teeth bracesupper and lower teeth braces)中填充三个特定的服务。

这是填充cmbBraces的代码:

 MySqlConn.Open()
        Dim ds6 As New DataSet
        Dim da6 As New MySqlDataAdapter
        Dim dt6 As New DataTable
        Dim cmd10 As New MySqlCommand

        With cmd10
            .Connection = MySqlConn
            .CommandText = "SELECT Service_Name FROM services"
        End With
        da6.SelectCommand = cmd10
        dt6.Clear()
        da6.Fill(ds6)
        Dim dt1 As DataTable = New DataTable
        dt6 = ds6.Tables(0)


        For Each dtRow As DataRow In dt6.Rows
            cmbBracess.Items.Add(dtRow(0))
        Next
        MySqlConn.close()

最佳答案

完成所需操作的最简单,最正确的方法是在服务表中添加另一列。假设调用此列的位类型为IsBrace(它可能只有两个值0或1)

现在,您应该为每个Services_Name的以下值设置此列

 Service_Name                             IsBrace
 --------------------------------------------------------------
 Extract                                  0
 Cleaning                                 0
 Jacket                                   0
 Upper teeth braces                       1
 lower teeth braces                       1
 upper and lower teeth braces             1


完成此操作后,您可以更改查询以仅检索IsBrace列设置为1的行。

 .CommandText = "SELECT Service_Name FROM services WHERE IsBrace = 1"

08-04 20:42