Possible typo in the first sub condition of your WHERE clause. I'm sure you
mean to say, "Data.title LIKE ", instead of "Data.titleLIKE".
Also, I don't think SQLite lets you write a parameterized query like this. I
think you have to concatenate the percents and your input string and pass the
concatenated string to sqlite3_bind_text16().
So, where query = "madonna", and path = "C:\MP3\Albums" you'd set
inquery="%madonna%", and inpath = "%C:\MP3\Albums%" then I might write the
query like:
SELECT
*
FROM
Data
WHERE
( Data.title LIKE ?
OR Data.artist LIKE ?
OR Data.album LIKE ?
OR Data.genre LIKE ?
OR Data.comment LIKE ?
OR Data.path LIKE ? )
AND Data.path LIKE ?;
and bind inquery and inpath. As others have pointed out, you might need to
escape the backslashes in path.
-Clark
----- Original Message ----
From: Jonas Sandman <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, October 30, 2006 1:31:02 PM
Subject: Re: [sqlite] Re: Re: Re: sqlite3_prepare16 and LIKE
#define SELECT_STATEMENT_TEXTSORT L"SELECT * FROM Data WHERE
(Data.titleLIKE (SELECT '%%' || ? || '%') OR
Data.artist LIKE (SELECT '%' || ? || '%') OR Data.album LIKE (SELECT '%' ||
? || '%') OR Data.genre LIKE (SELECT '%' || ? || '%') OR Data.comment LIKE
(SELECT '%' || ? || '%') OR Data.path LIKE (SELECT '%' || ? '%')) AND
Data.path LIKE (SELECT '%' || ? || '%');"
ERR = sqlite3_prepare16(m_db, SELECT_STATEMENT_TEXTSORT, -1, &exc,
(const void**)&tail);
wchar_t* errmsg = (wchar_t*) sqlite3_errmsg16(m_db);
sqlite3_bind_text16(exc, 1, query, -1, SQLITE_STATIC);
sqlite3_bind_text16(exc, 2, query, -1, SQLITE_STATIC);
sqlite3_bind_text16(exc, 3, query, -1, SQLITE_STATIC);
sqlite3_bind_text16(exc, 4, query, -1, SQLITE_STATIC);
sqlite3_bind_text16(exc, 5, query, -1, SQLITE_STATIC);
sqlite3_bind_text16(exc, 6, path, -1, SQLITE_STATIC);
while ((ERR = sqlite3_step(exc)) == SQLITE_ROW)
{
// process data here like:
// df->SetFileName((wchar_t*)sqlite3_column_text16(exc, 0));
}
path and query are wchar_t variables.
Jonas
On 10/30/06, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
>
> Jonas Sandman <[EMAIL PROTECTED]>
> wrote:
> > Yes, but path isn't part of the query. I ask for query = "", path =
> > "C:\MP3\Albums" and I get all the results in the entire database. If
> > I set query = "madonna" and same path. I get no results.
> >
> >> Use parentheses to achieve this result.
> >
> > Okay, that could've been it. But when I put that parenthesis in
> > there, I get no results ever. No matter of the query.
>
> Right. A condition on path is mandatory now, whereas before it could be
> false but you would still get results. This tells us that there's
> something wrong with the value you bind to path parameter.
>
> When you say "C:\MP3\Albums", are you literally hardcoding this string?
> If so, are you aware that backslashes should be escaped in C string
> literal?
>
> Show the actual code that calls sqlite3_bind_text[16] . There's
> something wrong there.
>
> Igor Tandetnik
>
>
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -----------------------------------------------------------------------------
>
>
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------