Helloo,
i am using a web service to autocomplete a textbox
The database contains a keywords column ..each colum contains more than 1 keywords LIKE "INDIA WORLD IRAQ"
So i need to use RegEx to split each keywords.
But How can i extract only strings that starts with the prefixtext into an array??
Please Helpp
I hav put my code below
1 public string[] GetKeywords(string prefixText, int count)
2 {
3 // int count = 10;
4 string connString = ConfigurationManager.ConnectionStrings["dnas_newConnectionString"].ToString();
5 string sqlselect = "SELECT TOP 10 Keywords FROM Page WHERE Keywords LIKE '%" + prefixText + "%'";
6 string[] keywords = new string[10];
7
8 int j = 0;
9 List keywordlist = new List<string>(count);
10
11
12 using (SqlConnection conn = new SqlConnection(connString))
13 {
14 conn.Open();
15
16 using (SqlCommand cmd = new SqlCommand(sqlselect, conn))
17 {
18 SqlDataReader dr = cmd.ExecuteReader();
19 while (dr.Read())
20 {
21
22 keywordlist.Add(dr["Keywords"].ToString());
23
24
25 keywords = Regex.Split(dr["Keywords"].ToString(), " ");
26
27
28 //int j = 0;
29 //for (int i = 0; i < keywords.Length; i++)
30 //{
31
32 // Match myMatch = Regex.Match(keywords[i], @"^" + prefixText + "");
33 // if (myMatch.Success)
34 // {
35 // items.SetValue(keywords[i], j);
36 // j++;
37 // }
38 //}
39 }
40 }
41
42
43
44
45
46 //return keywords;
47 }
48 //return items;
49 }
50 }
Regards
Faisal