Android Question Java.lang.illegalStateException

Rajesh Gupta

Member
Licensed User
Hii All

I am saving data in Sqlite Database, with one field of Data type MEMO, which contains around 7 MB of JSON data..

There is no problem in insertion, and when i am extracting data with SELECT query then this exception occurs.

Anyone please help...
 

Rajesh Gupta

Member
Licensed User
Please post the full error message from the logs.

java.lang.illegalstateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

This is the exception which I am getting.

Is the size of the field issue?
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
java.lang.illegalstateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

This is the exception which I am getting.

Is the size of the field issue?

copy the full error code, and also the code which you are using to retrieve the data.
 
Upvote 0

Rajesh Gupta

Member
Licensed User
copy the full error code, and also the code which you are using to retrieve the data.
B4X:
Try
      
    SQL1.Initialize(File.DirInternal, "Masters.db", True)

    Dim q As String = "SELECT Distinct * FROM tblLedgers WHERE PARTYNAME = '" & ddlaccname.Text & "' AND BDEPID = '" & GlobalConst.BDEPID &"' And CurFY = '" & GlobalConst.CurFY & "'"
    tblLedgers = SQL1.ExecQuery(q)

    If tblLedgers.RowCount > 0 Then
        tblLedgers.Position= 0
      
        Dim JsonFromDb As String = tblLedgers.GetString("PARTYJSON")
        Dim OpeningBal As Double = tblLedgers.GetDouble("OPBAL")
      
        ConvertJSONToDataTableinOFfflineMode(JsonFromDb, OpeningBal,True)
    Else
        Msgbox("No Data Found.", "Access Denied")
        pbaccledger.Visible = False
        ddlaccname.Enabled=True
        txtFrom.Enabled=True
        txtTo.Enabled=True
        btnaccledger.Enabled=True
        imgFrom.Enabled=True
        imgTo.Enabled=True
        End If
    Catch
        Log(LastException)
        Msgbox(LastException, "Exception Occured")
    End Try

I am getting the above exception in msg box when i am running the app.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code is wrong and will fail if the user enters a ' in one of the fields.
B4X:
 Dim q As String = "SELECT Distinct * FROM tblLedgers WHERE PARTYNAME = '" & ddlaccname.Text & "' AND BDEPID = '" & GlobalConst.BDEPID &"' And CurFY = '" & GlobalConst.CurFY & "'"
    tblLedgers = SQL1.ExecQuery(q)

Watch the SQL tutorial: https://www.b4x.com/etp.html

Comment the Try / Catch keywords and see the full error message.
 
Upvote 0

Rajesh Gupta

Member
Licensed User
This code is wrong and will fail if the user enters a ' in one of the fields.
B4X:
 Dim q As String = "SELECT Distinct * FROM tblLedgers WHERE PARTYNAME = '" & ddlaccname.Text & "' AND BDEPID = '" & GlobalConst.BDEPID &"' And CurFY = '" & GlobalConst.CurFY & "'"
    tblLedgers = SQL1.ExecQuery(q)

Watch the SQL tutorial: https://www.b4x.com/etp.html

Comment the Try / Catch keywords and see the full error message.

When i comment try catch, then it shows beginning of Main------
I think the problem is with the size of cursor limit, it is exceeding 1000 data sets or it is of 4 MB approx

This can be the reason?
 
Upvote 0
Top