Lesson 3 - databaseSearchNames?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Locked
saldroubi
Posts: 10
Joined: Sun Jul 28, 2013 2:16 am

Lesson 3 - databaseSearchNames?

Post by saldroubi » Tue Aug 27, 2013 4:18 am

databaseSearchNames is not working for me. I am not sure what I am doing wrong. The search for first or last name is not working for me. Actually it seems to work on some cases but not others.
For example if I search for "art" in then I get results but when I search for "rel" I should at least get the name "Darrel" but I don't.
Could anyone spot what is wrong with my code below. Also is the solution going to be posted. I wanted to compare my code against solution but I couldn't find it.
Thank you in advance for your help.
Sincerely,

------------------------------------------
on databaseSearchNames
--answer "in SearchName"
put the uText of group "searchText" into tSearchText
--answer tSearchText
put empty into field "contacts"
if the uOptionText of group "databaseType" is "SQLite" or the uOptionText of group "databaseType" is "Direct MySQL" then
--answer "In if"
put empty into field "contacts"
put "SELECT firstname,lastname,contact_id FROM contacts" into tSQLQuery
put " WHERE firstname LIKE '%" & tSearchText & "%' OR lastname LIKE '%" & tSearchText & "%'" after tSQLQuery
--put " WHERE firstname LIKE '%" & tSearchText & "%'" after tSQLQuery
--answer tSQLQuery
put revDataFromQuery(tab,return,sDatabaseConnectionID,tSQLQuery) into tContacts
else if the uOptionText of group "databaseType" is "Web MySQL" then
end if
put tContacts into field "contacts"
end databaseSearchNames

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Lesson 3 - databaseSearchNames?

Post by bangkok » Tue Aug 27, 2013 8:06 am

Please post here the query in plain words created by your script, so we can have a look.

With :

Code: Select all

answer tSQLQuery

saldroubi
Posts: 10
Joined: Sun Jul 28, 2013 2:16 am

Re: Lesson 3 - databaseSearchNames?

Post by saldroubi » Sun Sep 08, 2013 4:52 pm

I found the the problem. I think I a typo in the SQL string. It is working now.

Thank you

Locked

Return to “Summer School 2013”