Adsence750x90

Friday, March 28, 2008

Split String in C# ASP.Net - source code samples

Split String for Search Query


string a="splitting the qurey";
string[]splitString=a.Split(new char[]{' '});
string join=string.Empty;
string FullQuery = @"SELECT column1, column2 FROM table WHERE";

for (int i = 0; i < splitString.Length; i++)
{
join+= string.Format("(column3 LIKE '{0}%') OR ", splitString[i].ToString());
}
join = join.Remove(join.Length - 3);
FullQuery += join;

No comments: