Please stop changing the subject of this thread.
On Feb 19, 12:26 pm, Ward Willats <[email protected]> wrote:
> Strike that, you must NOT use quotes, so the 3 rules are:
>
> 1. Param array same size as number of wildcards
> 2. No null values
> 3. Don't surround ? with '?'
>
> Programming is hard.
>
> -- Ward
>
>
>
> >Answer:
>
> >Thou SHALT use a param string array that is exactly the same size as
> >the number of replacement params you have (no re-using a big one for
> >multiple queries like I was doing -- my example is misleading). [
> >This is arguably a bug, I think replacements should be driven by the
> >number of wildcards in the query, not the length of the param string
> >array provided, but... ]
>
> >Thou SHALT NOT pass null in any replacement param.
>
> >As an aside, it does not matter if you have the ? in single quotes
> >'?' or not. (Well, maybe it matters if your replacement token has
> >whitespace in it.)
>
> >-- Ward
>
> >>Something like this:
>
> >>String[] FooParams = new String[1];
> >>FooParams[0] = "123";
> >>Curosr csr =
> >> db.rawQuery( "SELECT * FROM FooTable WHERE FooField = '?'", FooParams
> >> );
>
> >>Causes this:
>
> >>android.database.sqlite.SQLiteException: bind or column index out of
> >>range: handle 0x30f6b0
>
> >>Everyone seems to use the convenience routines or concatenates their
> >>own strings together and passes "null" for the params. (Even the
> >>famous Busy Coder 2.0.2 pp 244). I can do that, of course, just
> >>wondering what stupid thing I am doing wrong or if it fails for
> >>everyone and that is why the idiom is not seen in the wild more...
>
> >>-- Ward- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---