首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#+SQL

2012-01-10 
c#+SQL 求助求助,看这条语句string.Format(select GoodsName from Goods where ID{0}, id)id为方法的

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[])
试试…

热点排行