【发布时间】:2016-10-13 01:31:56
【问题描述】:
我在显示我的数据库中保存的 BLOB 的组合框中得到重复项。
Private Sub refreshBLOBList()
Dim getBLOBListCommand As New SqlCommand( _
"SELECT DISTINCT FileName FROM DocumentStorage", dbConnection)
Dim reader As SqlDataReader
getBLOBListCommand.Connection.Open()
reader = getBLOBListCommand.ExecuteReader
While reader.Read
BLOBList.Items.Add(reader(0))
End While
reader.Close()
getBLOBListCommand.Connection.Close()
BLOBList.SelectedIndex = 0
End Sub
在这个块中,我刷新了组合框,但 DISTINCT 并没有摆脱组合框中的欺骗。奇怪的是,当我查询它并将其放入 datagridview 时,我得到了我想要的数据集。
有什么建议吗?
【问题讨论】:
-
我认为您需要在添加项目之前致电
BLOBList.Clear()。否则,您只需再次添加所有不同的新项 -
@FloatingKiwi 你是对的,这解决了我的问题。谢谢!
标签: sql vb.net visual-studio combobox blob