Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with DW8 generated Sql Select statement

Status
Not open for further replies.

aamaker

Programmer
Jan 20, 2002
222
US
Im trying to search a simple database of events, giving the user options to filter based on 3 parameters:

1.) a text / keyword string in the DESCRIPTION or NAME of the event

2.) a list menu (database generated) that allows them to select a CITY

3.) a list menu (also database generated) that allows them to choose an event category



It SEEMS to work but I keep finding bugs like it returning ALL when it shouldnt (i.e. City = Mayberry and text string = "music" or something like that.)

What could be the culprit here? I though I might need to add parenthesis around a part of the select statement like I've learned here on tek-tips before, but that doesnt correct the issue...

here is the code DW generated for my select statement:

Code:
Set RS_Events = Server.CreateObject("ADODB.Recordset")
RS_Events.ActiveConnection = MM_Events_Conn_STRING
RS_Events.Source = "SELECT *  FROM tbl_events  WHERE EventTitle Like '%" + Replace(RS_Events__MMColparam1, "'", "''") + "%' Or EventDetail Like  '%" + Replace(RS_Events__MMColparam1, "'", "''") + "%' And City = '" + Replace(RS_Events__MMColParam2, "'", "''") + "' And EventCategory Like '%" + Replace(RS_Events__MMColParam3, "'", "''") + "%'"
 
had to use parenthesis since Im mixing Like and Or in the select statement - works like a charm now thanks to a dude over in the ASP forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top