Beispiel #1
0
		public static string FilterContext(string source)
		{	// indexing service 
			//ms-help://MS.VSCC/MS.MSDNVS/indexsrv/ixrefqls_4qud.htm
			if(source == null || source.Trim().Length == 0)
				return "";
			StringBuilder filter = new StringBuilder();
			StringTokenizer srcItems = new StringTokenizer(source.Trim(), ' ', '"');
			if(srcItems.Count == 0)
				return "";
			foreach(string item in srcItems)
			{
				string pattern = item.Replace("'", "''");
				if(filter.Length > 0)
					filter.Append(" AND ");
				filter.Append(" \""  + pattern + "\" ");
			}
			return " CONTAINS(''" +  filter.ToString() + "'') ";
		}
Beispiel #2
0
		public static string FilterString(string field, string source)
		{
			if(source == null || source.Trim().Length ==0)
				return "";
			StringBuilder filter = new StringBuilder();
			StringTokenizer srcItems = new StringTokenizer(source.Trim(), ' ', '"');
			if(srcItems.Count == 0)
				return "";
			foreach(string item in srcItems)
			{
				string pattern = item.Replace("'", "''").Replace("%", "#%");
				
				if(filter.Length > 0)
					filter.Append(" AND ");
				filter.Append(" ( " + field + " LIKE '%" + pattern + "%' ESCAPE '#') ");
			}
			return filter.ToString();
		}