Dim cmd As New SQLCommand
Dim nt As DataTable
cmd.C
'Dim thmc As String = e.Form.Controls("ComboBox1").Selecteditem
Dim scx As String=e.Form.Controls("ComboBox1").Selecteditem
Dim fg As new List (of String)
fg.AddRange (e.Form.Controls("CheckedComboBox1").Selecteditem)
Dim lrs As Date= e.Form.Controls("DateTimePicker1").value
Dim lre As Date= e.Form.Controls("DateTimePicker2").value
If scx Is Nothing And fg Is Nothing And e.Form.Controls("DateTimePicker1").value Is Nothing Or e.Form.Controls("DateTimePicker2").value Is Nothing Then
MessageBox.Show("无最基本的查询条件")
e.Form.Controls("ComboBox2").Select
ElseIf scx IsNot Nothing And fg IsNot Nothing And e.Form.Controls("DateTimePicker1").value IsNot Nothing And e.Form.Controls("DateTimePicker2").value IsNot Nothing Then
cmd.CommandText = "Select * from {日常废品录入} where {日常废品录入}.[录入时间] between #" & lrs & "# and #" & lre & " # And {日常废品录入}.[发生工序] IN '" & e.Form.Controls("CheckedComboBox1").selecteditem & " 'And {日常废品录入}.[生产线f] = '" & scx & "'"
nt= cmd.ExecuteReader()
ElseIf scx Is Nothing And fg IsNot Nothing And e.Form.Controls("DateTimePicker1").value IsNot Nothing And e.Form.Controls("DateTimePicker2").value IsNot Nothing Then
cmd.CommandText = "Select * from {日常废品录入} where {日常废品录入}.[录入时间] between #" & lrs & "# and #" & lre & "# And {日常废品录入}.[发生工序] IN'" & e.Form.Controls("CheckedComboBox1").Selecteditem & "'"
nt= cmd.ExecuteReader()
ElseIf scx IsNot Nothing And fg Is Nothing And e.Form.Controls("DateTimePicker1").value IsNot Nothing And e.Form.Controls("DateTimePicker2").value IsNot Nothing Then
cmd.CommandText = "Select * from {日常废品录入} where {日常废品录入}.[录入时间] between #" & lrs & "# and #" & lre & "# And {日常废品录入}.[生产线f] = '" & scx & "'"
nt= cmd.ExecuteReader()
ElseIf scx Is Nothing And fg Is Nothing And e.Form.Controls("DateTimePicker1").value IsNot Nothing And e.Form.Controls("DateTimePicker2").value IsNot Nothing Then
cmd.CommandText = "Select * from {日常废品录入} where {日常废品录入}.[录入时间] >= #" & lrs & "# and {日常废品录入}.[录入时间] <= #" & lre & "# "
nt= cmd.ExecuteReader()
Else
MessageBox.Show("查询出错,请改变查询条件")
End If
Tables("废品流水表查询_Table1").DataSource =nt
DataTables("废品流水表查询_Table1").DataCols.Add("废品总重" ,Gettype(Double), "[单重]*[废品数量] ")
Tables("废品流水表查询_Table1").Cols("废品总重").Move(5)
'DataTables("废品流水表查询_Table1")
'e.Form.Controls("Table1").Visible=True
Tables("废品流水表查询_Table1").AutoSizeCols()
Tables("废品流水表查询_Table1").Cols("废品描述").Width=100
DataTables("废品流水表查询_Table1").dataCols("废品总重").SetFormat("#,###.0")
DataTables("废品流水表查询_Table1").dataCols("生产线f").Caption ="生产线"
DataTables("废品流水表查询_Table1").dataCols("材质规格f").Caption="材质规格"
DataTables("废品流水表查询_Table1").dataCols("订货单位f").Caption="订货单位"
请问如何在SQL语句中使用数组或者集合?
[此贴子已经被作者于2012-6-15 0:10:24编辑过]