以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请问如何在SQL语句中使用数组或者集合  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=20656)

--  作者:chenpan
--  发布时间:2012/6/15 0:09:00
--  请问如何在SQL语句中使用数组或者集合

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编辑过]

--  作者:狐狸爸爸
--  发布时间:2012/6/15 8:01:00
--  

你可以看看:

http://www.foxtable.com/help/topics/2410.htm

 

http://www.foxtable.com/help/topics/2228.htm

 


--  作者:chenpan
--  发布时间:2012/6/15 10:59:00
--  
狐爸你好,用了你的方法,好像不行!
--  作者:狐狸爸爸
--  发布时间:2012/6/15 11:20:00
--  

没有可能不行的,帮助的例子都是经过测试的。