cmd.CommandText = "Se1ect 表名,工程代码,Year(制单日期) As 年, Month(制单日期) As 月, Max(单据编号) as 单据编号 From {工程} Group By 表名,工程代码,Year(制单日期), Month(制单日期)"
dt = cmd.ExecuteReader flbhs.Clear() For Each dr As DataRow In dt.DataRows Dim qz As String = dr("表名") & "-" dr("工程代码") & "-" & dr("年") & Format(dr("月"),"00") '编号前缀,4位工程代码,4位年,2位月