title: Operand type clash: table type is incompatible with int while using table valued parameter
body: <p>I have a stored procedure like this:</p>
  
  <pre><code>  ALTER PROCEDURE [dbo].[T_TransactionSummary]  
                          @startDate datetime,  
                          @endDate datetime,
                         -- @locations integer
                         @locations dbo.Loc readonly
  
  AS
  BEGIN
      DECLARE @fromDate datetime = convert(varchar(10), @startDate, 121) + ' 00:00:00.000';
  DECLARE @toDate datetime = convert(varchar(10), @endDate, 121) + ' 11:59:59.999';
  
  SELECT     COUNT(*) AS CarCount, Location_tbl.LocName
  , REPLACE(CONVERT(varchar(11), Transaction_tbl.dtime, 113), ' ', '-') AS Date_time
  , CASE Transaction_tbl.Compl WHEN 'True' THEN 'Complementary' 
  WHEN 'False' THEN 'Non-Complementary' ELSE 'Other' END AS Expr1
  , VType_tbl.Vtype, CASE WHEN (VType_tbl.Vtype = 'Normal' AND Transaction_tbl.Compl = 'False') THEN COUNT(*) 
                        * 50 WHEN (VType_tbl.Vtype = 'VIP' AND Transaction_tbl.Compl = 'False') THEN COUNT(*) * 100 ELSE 0 END AS Total, 
                        CASE WHEN Transaction_tbl.Paid = 'False' THEN 0 ELSE SUM(Transaction_tbl.PAmount) END AS CIH
  FROM         Transaction_tbl INNER JOIN
                        Location_tbl ON Transaction_tbl.Locid = Location_tbl.Locid LEFT OUTER JOIN
                        VType_tbl ON Transaction_tbl.vtid = VType_tbl.vtid LEFT OUTER JOIN
                        Make_tbl ON Transaction_tbl.mkid = Make_tbl.mkid LEFT OUTER JOIN
                        Color_tbl ON Transaction_tbl.Colid = Color_tbl.colid LEFT OUTER JOIN
                        PlateSource_tbl ON Transaction_tbl.PSID = PlateSource_tbl.PSID
  WHERE     (Transaction_tbl.dtime BETWEEN @fromDate AND @toDate) 
  --AND (Location_tbl.Locid IN (@locations))
  AND (Location_tbl.Locid IN (select Lo from @locations))
  GROUP BY Location_tbl.LocName, REPLACE(CONVERT(varchar(11), Transaction_tbl.dtime, 113), ' ', '-')
  , VType_tbl.Vtype, Transaction_tbl.Compl, Transaction_tbl.Paid
  ORDER BY Location_tbl.LocName, Date_time DESC, VType_tbl.Vtype, Transaction_tbl.Compl
  
  END
  </code></pre>
  
  <p>My locid column 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</p>
  
  <pre><code>cnt = LSTlocations.SelectedItems.Count
    Dim dtlist As New DataTable()
      Dim locid As Integer
      If cnt &gt; 0 Then
          For i = 0 To cnt - 1
              dtlist.Columns.Add(locid, GetType(Integer))
              Dim locationanme As String = LSTlocations.SelectedItems(i).ToString
              locid = RecordID("Locid", "Location_tbl", "LocName", locationanme)
              dtlist.Rows.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
          Dim tvp1 As SqlParameter = cmd23.Parameters.AddWithValue("@locations", dtlist)
           tvp1.SqlDbType = SqlDbType.Structured
           tvp1.TypeName = "dbo.Loc"
          da.SelectCommand = cmd23
          da.Fill(ds) 
  </code></pre>
  
  <p>but i am getting error like this:</p>
  
  <blockquote>
    <p>Operand type clash: table type is incompatible with int  </p>
  </blockquote>
  
  <p>I know error is getting from "<code>AND (Location_tbl.Locid IN (select Lo from @locations))</code>" i am trying to pass muliple parameter to @locations,..thats why i am getting error..if any one know how to do it.please help me to find out..</p>