-4
我有表值參數是這樣的:未預期的操作數類型衝突:表類型爲int不兼容在執行存儲過程
CREATE TYPE [dbo].[Loc] AS TABLE(Lo integer)
我的存儲Proceurdure採取的位置ID是這樣的:
ALTER PROCEDURE [dbo].[T_TransactionSummary]
@startDate datetime,
@endDate datetime,
@locations dbo.Loc readonly
..........................
.........................
WHERE (Transaction_tbl.dtime BETWEEN @fromDate AND @toDate)
AND EXISTS (SELECT 1 FROM @locations WHERE lo = Location_tbl.Locid)
我的locid字段是整數這個locid來自我的listbox.if我選擇一個項目1 locid會come.if我選擇2項目2 locid會來..我有一個ListBox填充@locations參數(整數),我把我的列表框的值如下
cnt = LSTlocations.SelectedItems.Count
Dim dtlist As New DataTable()
Dim locid As Integer
If cnt > 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)
,但我得到的錯誤是這樣的:
操作數類型衝突:表類型爲int
不相容什麼是錯我的代碼和存儲過程
[操作數類型衝突表類型在將參數傳遞給存儲過程時與int不兼容](http://stackoverflow.com/questions/19615532/operand-type-clash-table-type-is-incompatible-with -int-while-passing-parameter-t) – bummi
先生,我還沒有得到這個問題的答案..請 – user2878851