Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T
Accepted Solution

Statement Unprepared error

OS 7.1

SQLite DB

 

I am creating a screen with 3 pill buttons.  The first pill button shows a detail screen from the item selected from a previous screen.  The second and third pills show lists of items related to the main item selected.  I use a cursor from the main screen to hold the information from the detail screen.  When I got to the second pill and try to get list of items, I get a database error on the cursor "Statment Unprepared"

 

Cursor tagsCursor = null;
		try
		{
			Statement statement;
			// Get Single Site
			statement = SQLManager.appDB.createStatement("SELECT Key, iBase, SiteBPNumber, " 
					+ "CurrentMeterCount, LaborWarrantyFlag FROM " 
					+ tableName 
					+ " WHERE SiteBPNumber = ? "); 
			statement.bind(1, siteBPNumber);
			statement.prepare();
			tagsCursor = statement.getCursor();
		} catch (DatabaseException de) {
			SDApp.handleException(de, "Get Tag Query");
		}
		
		return tagsCursor;

 This is a similar query to the one that gets the Cursor for the first screen list and detail.

 

I haven't found any solution to this error.  I think it might have to do with the database connection being already open with the previous Cursor.  But, if I close the Cursor for the first screen list and detail, then I get an error on that Cursor.

 

I'm not sure what I should do on this.

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Highlighted
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Statement Unprepared error

Nevermind.  I think I need a vacation.

 

You need to prepare before binding.

So, this

statement.bind(1, siteBPNumber);
statement.prepare();

 Should be this

statement.prepare();
statement.bind(1, siteBPNumber);

 

Oh well.  That wasted a bunch of my time.

 

Also.  I use a function that brings back a cursor.  After I populate the list from the cursor, I closed that cursor and it seems to have worked fine.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment