我有一个具有以下标准的存储过程:
WHERE (Transaction_tbl.dtime BETWEEN @fromDate AND @toDate)
AND (Location_tbl.Locid IN (@locations))
我有一个 ListBox 填充@locations
参数(一个整数),以及两个 DateTimePicker 控件用于@fromDate
和@toDate
。
我把我的列表框值是这样的:
cnt = LSTlocations.SelectedItems.Count
Dim list As New List(Of Integer)
Dim locid As Integer
If cnt > 0 Then
For i = 0 To cnt - 1
Dim locationanme As String = LSTlocations.SelectedItems(i).ToString
locid = RecordID("Locid", "Location_tbl", "LocName", locationanme)
list.Add(locid)
Next
End If
我想将此列表项值传递给我的存储过程...我该怎么做?
cmd23.Parameters.Add("@startDate", SqlDbType.NVarChar, 50, ParameterDirection.Input).Value= startdate
cmd23.Parameters.Add("@endDate", SqlDbType.NVarChar, 50, ParameterDirection.Input).Value = enddate
cmd23.Parameters.Add("@locations", SqlDbType.Int) ' <= ???
如何修改此代码以将多个整数标识符作为@locations
参数传递,以便我可以在列表框中选择多个项目?