在C#.net Windows应用程序中拆分字符串 [英] Split String in C# .net Windows Application
本文介绍了在C#.net Windows应用程序中拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像设计,网站等数据库,如果我搜索像W这样的数据,那么它在我的gridview中显示网站,那么如何在storeprocedure或c#中编写此查询编码...?
Hi,
I have a database like Design,Website,etc and if i search a data like word W then it shows Website in my gridview so how can i write this query in storeprocedure or c# coding...?
推荐答案
使用通配符搜索
Use wildcard search
CREATE PROC [dbo].[StoredProcedureName]
(
@Parametername nvarchar(50)
)
AS
SELECT ColumnName FROM TableName
WHERE ColumnName LIKE '%' + @Parametername
'%' ria意味着任何以你的标准开头的东西,最后意味着结束。之前和之后,将带来包含您给定值的结果......
'%' before you criateria mean anything that starts with your criteria, at the end meant end with. Before and after, will bring results containing your given value...
有很多可用的方法...
从TABLENAME中选择*其中FIELDNAME像'W %'
将w作为参数...传递给存储过程
或
您可以使用DeExpress Grid,并在其中启用自动过滤行。
A lot of methods available...
select * from TABLENAME where FIELDNAME like 'W%'
pass w as parameter...to the Stored Procedure
OR
You can Use DeExpress Grid , ANd Enable AutoFilter Row in it.
string strsql = "SELECT Tags from Table_Name WHERE Name LIKE @p";
SqlCommand cd1 = new SqlCommand(strsql , con);
cd1.Parameters.Add("@p", SqlDbType.NVarChar).Value = p + "%";
SqlDataReader rdr = cd1.ExecuteReader() ;
之后你必须阅读阅读器,即你必须使用While循环阅读阅读器。
while(rdr.Read(){}做你想做的业务逻辑。
这篇关于在C#.net Windows应用程序中拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文