设置下拉框,选择月份后,点击查询命令按钮,执行代码如下:
Dim dt As DataTable
Dim cmd As new SQLCommand
Dim ids As String
Dim box2 As WinForm.ComboBox= e.Form.Controls("ComboBox2")
Dim m As Byte = cbyte (box2.text)
cmd.CommandText = "Select [_Identify],部门,姓名,出生年月 From {基本信息} where month(出生年月)=month("& m &")"
dt = cmd.ExecuteReader
For Each dr As DataRow In dt.dataRows
ids = ids & "," & dr("_identify")
Next
ids = "(" & ids.trim(",") & ")"
ids = "Select [_Identify],部门,姓名,出生年月 From {基本信息} Where [_Identify] in " & ids
Tables("本月生日员工_Table1").Fill(ids,"",False)
Tables("本月生日员工_Table1").AllowEdit = False
但只得到12月、1月的名单,错在哪里?
另:代码是不是繁琐了点?