hi
i want make Eshop and i have database
Id
|
Name
|
Key1
|
Key2
|
Key3
|
1
|
Hotel
|
Hotel
|
Travel
|
Room
|
2
|
Training
|
English
|
Computer
|
Sport
|
3
|
Food
|
Fast food
|
Restaurant
|
Salad
|
this is example of my table ,column key1,key2,key3 is some keyword that when customer write this keyword in textbox and click search button ,it will show page that put on name column EX:when write travel in TB it will show hotel page .
how i can show my all key words in TB i use jquery search engine and put this code but Occur error :
<%@ WebHandler Language="C#" Class="Search_CS" %> using System; using System.Web; using System.Data.SqlClient; using System.Configuration; using System.Text; public class Search_CS : IHttpHandler { public void ProcessRequest (HttpContext context) { string prefixText = context.Request.QueryString["q"]; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager .ConnectionStrings["behtopConnectionString"].ConnectionString; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select Key1,Key2,Key3 from Trades where " + "Key1,key2,key3 like @SearchText + '%'"; cmd.Parameters.AddWithValue("@SearchText", prefixText); cmd.Connection = conn; StringBuilder sb = new StringBuilder(); conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { sb.Append(sdr["key1"]) .Append(Environment.NewLine); } } conn.Close(); context.Response.Write(sb.ToString()); } } } public bool IsReusable { get { return false; } } }
****************ٍERROR********************
An expression of non-boolean type specified in a context where a condition is expected, near ','.
when i change this code it run correctly
what can i do?
cmd.CommandText = "select Key1,Key2,Key3 from Trades where " + "Key1,key2,key3 like @SearchText + '%'";
cmd.CommandText = "select Key1,Key2,Key3 from Trades where " + "Key1 like @SearchText + '%'";<