Posts

Showing posts with the label exception

while/try/except decimal TypeError not working

while/try/except decimal TypeError not working I thought I could finally get some use out of the while/try/except loop, but I am encountering a problem. My task is to have the computer request numbers from a user until '0' is entered. After this, the numbers entered will be added. My problem is that the Except part isn't catching non-numeric entries. If a non-numeric entry is entered, I get a regular error message that stops the program. Here is what happens when I enter 3 numbers and the 4th entry is 'm': on win32 Type "copyright", "credits" or "license()" for more information. >>> RESTART: C:/Users/Username/Documents/CISPROG1/Homework 5/Homework5.1.SumGenerator.py Enter 1st element (or type '0' to finish). 1 Enter 2nd element (or type '0' to finish). 2 Enter 3rd element (or type '0' to finish). 3 Enter 4th element (or type '0' to finish). m Traceback (most recent call last): File "C:/...

SQLiteException when querying a SELECT [on hold]

SQLiteException when querying a SELECT [on hold] I am developing an Android application with an SQLite database. It records transactions. The transactions table has the colums: transactions idTransaction INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT date DATE NOT NULL type INT NOT NULL details VARCHAR(100) NOT NULL notes VARCHAR(300) NOT NULL amount DOUBLE NOT NULL account INT NOT NULL category INT NOT NULL Also I made a method to get a cursor with all transactions: // Select all Transactions protected Cursor getTransactions() throws SQLException { Cursor mCursor = null; String colums = new String{"idTransaction", "date", "type", "details", "notes", "amount", "account", "category"}; mCursor = this.getReadableDatabase().query("Transactions", colums, null, null, null, null, "name ASC"); return mCursor; } In other class I made a method to move through the cursor that I get whe...