飞兄:请教教我怎么写代码,我的排班键的代码是:
Dim i As new SQLCommand
Dim dt As DataTable
i.C
i.CommandText ="SELECT * from {XR人事表} where 离职日期 Is Null"
dt =i.ExecuteReader '选取在职员工
Dim fd As Date =e.Form.Controls("qsr").value
Dim nd As Date =e.Form.Controls("zzr").value
Dim tsc As TimeSpan =nd -fd
Dim ts As Integer =tsc.TotalDays
Dim rq As Date
Tables("KQ考勤排班表").StopRedraw
If e.Form.Controls("qsr").value IsNot Nothing And e.Form.Controls("zzr").value IsNot Nothing Then '选取排班日期
For l As Integer =0 To ts
Dim fi As new Filler
fi.SourceTable =dt
fi.SourceCols ="编号,卡号,岗位编号,班级"
fi.DataTable =DataTables("KQ考勤排班表")
fi.DataCols ="工号,卡号,岗位编号,班级"
fi.Fill() '填充数据进排班表
Next
Else
messagebox.show("请正确选择起始及终止日期")
Return
End If
Dim drs As List(of DataRow) =DataTables("KQ考勤排班表").Select("")
Dim hs As Integer =(drs.count-1)/(ts+1)-1
Dim s As Integer
For c As Integer =0 To ts
rq =fd.AddDays(c)
For ii As Integer =0 To hs
s =1+s
drs(s-1)("日期") =rq
Next
Next '填加日期进排班表
Tables("KQ考勤排班表").ResumeRedraw
代码的大意是从后台的人事表中选取在职的人员,然后将相关资料填充进排班表,然后再将所选日期排进排班表,但现在的情况是所有数据都进了排班表中,不知怎么才能按您的意思直接进SQL SERVER呢,请赐教!