日期:2014-05-18  浏览次数:20635 次

c#+SQL 求助
求助,看这条语句 

string.Format("select GoodsName from Goods where ID='{0}'", id) 

id为方法的参数 

问题:当id为一个数组的时候这条语句怎么写?因为id是别的方法返回的 
string[] 要是循环这个数组一条一条查的话几十万条记录不卡死~~ 

我记着好像可以select GoodsName from Goods where ID in ??? 
怎么写 
是oracle数据库 
或者有什么别的方法?讲究效率,因为别的方法返回的是个参数数组string []

------解决方案--------------------
string.Format("select GoodsName from Goods where ID in {0}", string[]) 
试试…


------解决方案--------------------
VB.NET code

        Dim id() As String = {"1", "2", "3"}

        Dim str As String = String.Empty

        For Each s In id
            str = str & s & ","
        Next


        str = String.Format("select GoodsName from Goods where ID in ({0})", str.Substring(0, str.Length - 1))

        MessageBox.Show(str)

------解决方案--------------------
探讨
string.Format("select GoodsName from Goods where ID in {0}", string[])
试试…