我有這樣一個存儲過程:存儲過程總是把第一個參數從代碼
ALTER PROCEDURE [dbo].[T_TransactionSummary]
@locations nvarchar
AS
BEGIN
..............
.............
AND (Location_tbl.Locid IN (@locations))
我LOCID字段是整數 這LOCID從我listbox.if未來我選擇一個項目1 LOCID會來。如果我選擇2項2 LOCID會來.. 我有它填充@locations參數(整數)的列表框,我把我的列表框的值這樣的
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
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd23 As New SqlCommand("T_TransactionSummary", con.connect)
cmd23.CommandType = CommandType.StoredProcedure
cmd23.Parameters.Add("@locations", SqlDbType.Int).Value = String.Join(",", list)
da.SelectCommand = cmd23
da.Fill(ds)
現在從列表框中我locationid在流逝僅存儲過程1,2,3 。但存儲過程總是取第一個值(我的意思是在這種情況下取1)。
您是否首先執行了任何簡單的調試?像'PRINT @locations;'? –
不,先生...爲什麼我必須這樣做? – user2878851
因爲在這種情況下,它會顯示您傳遞的值正在被截斷。 –