New topic: Search in a database
<http://forums.realsoftware.com/viewtopic.php?t=31431> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message Railfanner Post subject: Search in a databasePosted: Sat Dec 05, 2009 11:26 pm Joined: Sat Jan 07, 2006 10:03 pm Posts: 65 Location: Central Canada So far, it its much better. Now I am searching for a phrase in my database, here is the code. I am looking for a word/phrase in the title part of the database. Displaying the found titles it in a listbox. If I search for "....CDTitle =" the code does work, but not for a partial word/phrase search. The error is indicated to be at "while not rs.eof" Code: Dim rs as RecordSet dim sql as string addtitleef.text = "Christmas" sql = "select * from CDFiles where CDTitle CONTAINS '" + addtitleef.text + "'" rs = CDsdb.SQLSelect(sql) while not rs.eof listbox1.addrow (rs.Field("CDCategory").StringValue) listbox1.cell(listbox1.LastIndex,1) = rs.Field("CDAuthor").StringValue listbox1.cell(listbox1.LastIndex,2) = rs.Field("CDTitle").StringValue listbox1.cell(listbox1.LastIndex,3) = rs.Field("CDNoFile").StringValue listbox1.cell(listbox1.LastIndex,4) = rs.Field("CDSize").StringValue listbox1.cell(listbox1.LastIndex,5) = rs.Field("CDLocation").StringValue listbox1.cell(listbox1.LastIndex,6) = rs.Field("CDComment").StringValue rs.MoveNext wend rs.Close Any thoughts. I hope it is something small since I feel I am on the right track. Top dglass Post subject: Re: Search in a databasePosted: Sun Dec 06, 2009 12:23 am Joined: Fri Sep 30, 2005 9:29 am Posts: 676 Location: California What DB engine uses CONTAINS in that way? I would think you would want either: Code:"LIKE '%" + addtitleef.text + "%'" for those engines that don't recognize CONTAINS, or Code:"CONTAINS (CDTitle, '" + addtitleef.text + "') > 0" Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
