Re-reading the previous emails, it appears I also need to use sqlite3_bind_*().

On Thu, Jan 26, 2017 at 9:04 AM, Clyde Eisenbeis <cte...@gmail.com> wrote:
> I've also tried:
>
>   string stCmdString = "SELECT" + stFieldNames + "FROM " + stTableName
> + " WHERE " + stLikeFieldName + " LIKE ('%' || " +
> liststLikeFieldValue[0] + " || '%')";
>
> which does not work.
>
> On Thu, Jan 26, 2017 at 8:14 AM, heribert <herib...@scharnagl.com> wrote:
>> There are some missing spaces i think:
>>
>> string stCmdString = "SELECT " + stFieldNames + " FROM " + stTableName
>> + " WHERE " + stLikeFieldName + " LIKE '%'||" +
>> liststLikeFieldValue[0] + "||'%'";
>>
>> Am 26.01.17 um 15:04 schrieb Clyde Eisenbeis:
>>>
>>> I tried replacing this:
>>>
>>>
>>>    string stCmdString = "SELECT" + stFieldNames + "FROM " + stTableName
>>> + " WHERE " + stLikeFieldName + " LIKE '%" + liststLikeFieldValue[0] +
>>> "%'";
>>>
>>> with this:
>>>
>>>    string stCmdString = "SELECT" + stFieldNames + "FROM " + stTableName
>>> + " WHERE " + stLikeFieldName + " LIKE '%'||" +
>>> liststLikeFieldValue[0] + "||'%'";
>>>
>>> Does not work.
>>>
>>> On Wed, Jan 25, 2017 at 11:53 AM, Richard Hipp <d...@sqlite.org> wrote:
>>>>
>>>> On 1/25/17, Warren Young <war...@etr-usa.com> wrote:
>>>>>
>>>>> stCmdString += " AND ‘%?1%’ LIKE ‘%?2%’”;
>>>>>
>>>>> Then use the sqlite3_bind_*() calls to insert parameters 1 and 2 into
>>>>> the
>>>>> string.
>>>>
>>>> Not quite.  You cannot have parameters embedded in the middle of
>>>> strings.  The whole string is replaced by a parameter.
>>>>
>>>>     stCmdString += " AND fstInfo LIKE ?1 AND fstInfo LIKE ?2"
>>>>
>>>> Then the application has to prepend and append the "%" on the strings
>>>> before binding.  Or, if your application does not want to do that:
>>>>
>>>>     stCmdString += " AND fstInfo LIKE ('%' || ?1 || '%') AND fstInfo
>>>> LIKE ('%' || ?2 || '%')"
>>>>
>>>> Then you can bind the search patterns directly to ?1 and ?2.  (Aside:
>>>> || is the string concatenation operator in SQL.)
>>>>
>>>> --
>>>> D. Richard Hipp
>>>> d...@sqlite.org
>>>> _______________________________________________
>>>> sqlite-users mailing list
>>>> sqlite-users@mailinglists.sqlite.org
>>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>>
>>> _______________________________________________
>>> sqlite-users mailing list
>>> sqlite-users@mailinglists.sqlite.org
>>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to