Good day guys! I'm having a hard time fixing this code to display the total of a column to the label.
Here's my code:
and here's the error:
"salesentry_btnadd_click (B4A line: 334)
lblTotal.Text = Main.cursor1.GetString("totalOr
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:426)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
at MPOS.bermzSolutions.salesentry._btnadd_click(salesentry.java:901)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4856)
at android.view.View$PerformClick.run(View.java:19956)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1"
Guys please help me.. thanks you so much.
Here's my code:
B4X:
Main.cursor1 = Main.sql1.ExecQuery("SELECT SUM(prodTotal) as totalOrdered FROM tblSales where orNum like '" & Label7.Text & "'")
For i = 0 To Main.cursor1.RowCount - 1
lblTotal.Text = Main.cursor1.GetString("totalOrdered")
Next
and here's the error:
"salesentry_btnadd_click (B4A line: 334)
lblTotal.Text = Main.cursor1.GetString("totalOr
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:426)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:355)
at MPOS.bermzSolutions.salesentry._btnadd_click(salesentry.java:901)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4856)
at android.view.View$PerformClick.run(View.java:19956)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1"
Guys please help me.. thanks you so much.