Vb.net 将多个整数变量同时传递给integer参数
我有一个具有以下条件的存储过程:Vb.net 将多个整数变量同时传递给integer参数,vb.net,listbox,Vb.net,Listbox,我有一个具有以下条件的存储过程: WHERE(在@fromDate和@toDate之间的事务时间) 和(@locations中的Location_tbl.Locid)) 我有一个用于填充@locations参数(一个整数)的列表框,还有两个用于@fromDate和@toDate的日期时间选择器控件。 我的列表框值如下所示: cnt = LSTlocations.SelectedItems.Count If cnt > 0 Then For i = 0
WHERE(在@fromDate和@toDate之间的事务时间)
和(@locations中的Location_tbl.Locid))
我有一个用于填充@locations
参数(一个整数)的列表框,还有两个用于@fromDate
和@toDate的日期时间选择器控件。
我的列表框值如下所示:
cnt = LSTlocations.SelectedItems.Count
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) ' <= ???
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)”您可以尝试将所选整数连接成逗号分隔的字符串,然后将其传递到存储过程中
然后,您可以使用它将CSV字符串转换为表格
然后,您可以将该表变量与“Location\u tbl.Locid”的内部联接一起使用
可能的副本。这篇文章是针对C#,但我猜它对于VB基本上是一样的。这里我必须传递整数变量。先生。我必须更改我存储过程中的任何内容。我认为传递整数并不重要,因为值是一个对象。请看:先生,那么我如何重新编写我的代码呢。。??
@Locations VARCHAR(MAX) --Your inbound CSV list of LocID's
.
.
.
DECLARE @MyTable TABLE
(LocID VARCHAR(50))
INSERT INTO @MyTable
(LocID)
SELECT dbo.Split(@Locations, ',') --This is the function from the aforementioned POST
.
.
SELECT * FROM [your list of tables]
INNER JOIN @MyTable L ON Location_tbl.Locid = L.LocID
WHERE (Transaction_tbl.dtime BETWEEN @fromDate AND @toDate)