Last Reply on Feb 21, 2012 12:58 AM By Mudassar

Views: 269   Replies: 7  Answers: 2


nedash

262 Points
Novice
Joined: Jan 30, 2012 12:39 AM
Replies: 125
on Feb 11, 2012 12:50 AM

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 + '%'";<

 

1


You are viewing reply posted by: Mudassar on Feb 21, 2012 12:58 AM. Show All

Mudassar

11323 Points
Expert
Joined: Nov 11, 2011 05:52 PM
Replies: 1849
Location: Mumbai, India
0
Permanent Link on Feb 21, 2012 12:58 AM

Then please mark the reply that helped as answer or add a new reply and tell us how you solved it and mark it as answer for others

MVP ASP.Net

© 2012 www.aspforums.net All rights reserved. Powered by Excelasoft Solutions.  Excelasoft Solutions

Disclaimer: This site is started with intent to serve the ASP.Net Community by providing forums (question-answer) site where people can help each other. The content posted here is free for public and is the content of its poster. The site does not provide any warranties for the posted content. If you feel any content is violating any terms please contact.