I would say that it was the format of your query.  Is one of your
parameters a string and would need quoting, is the time format correct
etc?

Try replacing your parameterised query with a simple string (with no
parameters) that you have previously tested in the SQLite shell.  Then
start putting back one parameter at a time and test each time.

Hope this helps

--
RichardC

On Oct 22, 8:02 am, brucko <geoff.bruck...@gmail.com> wrote:
> Thanks, but I tried that earlier. moveToFirst() also calls count() and
> results in same error ... sigh
>
> On Oct 22, 5:08 pm, zhen guo <mguoz...@gmail.com> wrote:
>
> > before getCount,  you should add cursor.moveToFirst().
>
> > On Thu, Oct 22, 2009 at 1:05 PM, brucko <geoff.bruck...@gmail.com> wrote:
>
> > > I'm having trouble with a SQLite database that I have on the SDCard.
>
> > > when I do a query that returns a cursor I keep getting an error when i
> > > try to call the count() method.
>
> > > Here's the code
>
> > > Cursor cursor = mDb.query
> > > (LOGON_TABLE,                                        // table
> > >                                new String[] { KEY_ROW_ID },
> > >            //
> > > columns,
> > >                                KEY_USER_NAME + " = ? AND " +
> > >                                                KEY_CARRIER_ID + " = ? AND 
> > > "
> > > +
> > >                                                KEY_DEPOT + " = ? AND " +
> > >                                                KEY_TIME + " = ? AND " +
> > >                                                KEY_RUN + " = ?",
> > >                   //selection,
> > >                                new String[] { user, carrier, depot,
> > > logonTime, run },//
> > > selectionArgs,
> > >                                null, null, null,
> > >                     //
> > > groupBy, having, orderBy
> > >                                " 1
> > > ");                                                                //
> > > limit
>
> > >                if (cursor.getCount() < 1) {        <--error occurs here
> > >                         ...
> > >                }
>
> > > It  gives a datatype mismatch as a result of calling count...
>
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):
> > > android.database.sqlite.SQLiteException: datatype mismatch
>
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:288)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.AbstractCursor.moveToPosition(AbstractCursor.java:
> > > 171)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > android.database.AbstractCursor.moveToFirst(AbstractCursor.java:248)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > com.paperfree.database.DatabaseService.insertLogon
> > > (DatabaseService.java:288)
> > > 10-22 04:20:21.330: ERROR/AndroidRuntime(15768):     at
> > > com.paperfree.load.LoadView$2.onServiceConnected(LoadView.java:76)
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):
> > > android.database.sqlite.SQLiteException: datatype mismatch
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):     at
> > > android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):     at
> > > android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):     at
> > > android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:288)
>
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):     at
> > > android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
>
> > > 10-22 04:53:20.471: ERROR/AndroidRuntime(22252):     at
> > > com.paperfree.database.DatabaseService.insertLogon
> > > (DatabaseService.java:268)
>
> > > The database file is on the sdCard and all the columns are there, but
> > > I haven't put any data there so I am expexcting a cursor with zero
> > > rows.
>
> > > Thanks
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to