开发者

ODBC Parameters with List of Values

开发者 https://www.devze.com 2023-03-11 16:47 出处:网络
A little outside my comfort zone... Is there any way to pass multiple values (a list of values) to a query via ODBC Parameters in VB.Net?

A little outside my comfort zone...

Is there any way to pass multiple values (a list of values) to a query via ODBC Parameters in VB.Net?

For instance, is there a way to create a query along the lines of开发者_开发知识库:

-- vb.net has something like Dim itemNumbers As New List(Of Integer)(SomeCount)

SELECT Cost, Description
FROM   MyItemList
WHERE  ItemNum IN (<my list of item numbers>)

Thanks!


Unfortunately ODBCParameter can hold only a single value. It might be easier to do something like this

cmd.CommandText = "SELECT Cost, Description FROM   MyItemList WHERE  ItemNum IN (@Items)"
cmd.Paramaters.AddWithValue("@Items", String.Join(", ", itemNumbers.Select(Function(i) i.ToString())))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号