示例一
Dim cmd As New SQLCommandDim dt As DataTableDim cmb As WinForm.ComboBoxcmd.CommandText = "SELECT DISTINCT a.合同编号 From {合同表} as a inner join (select 关联标识, max(关联序号) as 关联序号 from {合同表} group by 关联标识) as b on a.关联标识=b.关联标识 where a.关联序号=b.关联序号"
dt = cmd.ExecuteReader()cmb = e.Form.Controls("ComboBox1")cmb.ComboList= dt.GetComboListString("合同编号")
上述代码可以设置在窗口的AfterLoad事件中。