开发者

want to Search more then 2 keywords in ASP.net C#.net

i want to Search more then 2 item with one TEXTBOX field using with , Eg. item1,item2.

Result should be shown for both in one 开发者_如何学Cgridview i am using SP with one Parameter.


In the SP you will have to split the value.

Something like

--Split
DECLARE @textXML XML
DECLARE @data NVARCHAR(MAX), 
        @delimiter NVARCHAR(5)

SELECT  @data = 'A,B,C',
        @delimiter = ','

SELECT    @textXML = CAST('<d>' + REPLACE(@data, @delimiter, '</d><d>') + '</d>' AS XML)
SELECT  T.split.value('.', 'nvarchar(max)') AS data
FROM    @textXML.nodes('/d') T(split)

Then You can use this in an WHERE IN claues or join to the SELECT as a SUB SELECT or CTE statement


in C#, split your values and pass it to SQL like @astander told,

you can use like,

       var Values = Split(Textbox.text) //Textbox.Text.Tostring().Split("Delimeter")

       now you can access array, like

       Values[0]

       Values[1]

Pass this to SQL query

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜