I have a stored procedure like this:
ALTER PROCEDURE [dbo].[T_TransactionSummary]
@locations nvarchar
AS
BEGIN
..............
.............
AND (Location_tbl.Locid IN (@locations))
my locid field is integer this locid coming from my listbox.if i select one item 1 locid will come.if i select 2 item 2 locid will come.. I've got a ListBox which populates the @locations parameter (an integer), I took my listbox value like this
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)
now my locationid from listbox is passing to stored procedure 1,2,3, only . but stored procedure always taking first value(i mean in this case taking 1).