Android Question Problem with Connecting Android to MySQL Database

Status
Not open for further replies.

Shubhankar

Member
Licensed User
I refer to the Mysql tutorial

In the tutorial a two line custom type is used

If I want to get more than 2 responses form the server do I still use twolines as a custom type?
I tried using five lines but it doesnt work
Is there a generic type i can use for multiple return values
 

Shubhankar

Member
Licensed User
I dont really understand
I am using your example and wish to have more than 2 values
I quote from your comments in the example
"We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item."

so what shld i declare instead of two lines ?
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I want my list generated to have 5 different sets of data instead of 2 'per country'

It's always good to post an example...

You need to add more rows/culumns to you table. Please notice that there will be ONE request and ONE result at a time, not two. It's up to you to return the data as you need by modifiying the request.

It's like an order in a restaurant. You get what you order.
 
Upvote 0

Shubhankar

Member
Licensed User
Under sub Job done I have this part written
Dim tl As TwoLines
tl.First = m.Get("id")
tl.Second = m.Get("course_name")
' tl.course_desc=m.Get("course_desc")
' tl.course_days= m.Get("course_days")
' tl.course_rating= m.Get("course_rating")

The programme only works if I comment off the last 3. I feel the problem is with the Twolines part. Hope you can help :)
 
Upvote 0

Shubhankar

Member
Licensed User
Decided to put my example up
Also when I run the programme and click on my list I get an error saying
" error in sub:main_jobdone(java line 477)
java.lang.NumberFormatException:Invalid double:"null"
 

Attachments

  • tryingmysql.zip
    142 KB · Views: 179
Last edited:
Upvote 0

Shubhankar

Member
Licensed User
Managed to fix the initial problem of showing more than one entry but now I am unable to display the database info upon clicking
i get an error saying from job done saying object should be initialised first (label)
Thanks for ur help @Erel
 

Attachments

  • tryingsqlv2.zip
    144.4 KB · Views: 196
Upvote 0

Shubhankar

Member
Licensed User
@Erel I am uploading my updated code as well
 

Attachments

  • errorlogs.PNG
    errorlogs.PNG
    79.1 KB · Views: 189
  • tryingsqlv3.zip
    147.7 KB · Views: 178
Upvote 0

Shubhankar

Member
Licensed User
hey @Erel

i am still having problems. i already initialised all the members. The issue i am having is upon clicking. I want to create something along these lines. When I open the app i see the list ( which is obtained from the database) then when i click it opens coursesv3 and gets the data from the database again. I made a activity module so i can choose options and go back to the list. However in the activitity module my tl is unrecognised despite initialising it. Also i am unsure if the module is able to retrieve the value through Main.tl.course_desc. Or should i place it like this Main.jobdone.tl.course_desc?

Hope you understand and can help
Thanks!!
 

Attachments

  • 2ndjanproblem.zip
    148.7 KB · Views: 206
Upvote 0

Shubhankar

Member
Licensed User
Hey @Erel
Solved all the errors
having an error now on line 38 in the open folder activity . I am unable to refer to the function from the main.

Also the initial problem still persists. (the problem in job done)
 

Attachments

  • remotequery problem.zip
    148 KB · Views: 202
  • Capture.PNG
    Capture.PNG
    59.3 KB · Views: 199
Upvote 0

Shubhankar

Member
Licensed User
Logs are only available in debug mode when connected with B4A-Bridge.
LogCat connected to: B4A-Bridge: samsung GT-P5113
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
Response from server: [{"id":"1","course_name":"Basic Excel 2013","course_desc":"Learn basic to intermediate functions of Excel. Simple formulas and features of Microsoft Excel 2013","course_days":"2 Days.","course_rating":"4.68"},{"id":"2","course_name":"Advanced Excel 2013","course_desc":"Learn Pivot Tables, VLookup, Macros & Advanced Functions of Excel.","course_days":"2 Days.","course_rating":"4.87"},{"id":"3","course_name":"Introduction to SQL","course_desc":"Learn to create a SQL database, query a database table and select, insert, update & delete records.","course_days":"2 Days.","course_rating":"4.89"},{"id":"4","course_name":"Facebook Marketing for Business","course_desc":"Learn to use Facebook for marketing your business on your own.","course_days":"1 Day","course_rating":"4.79"}]
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
Response from server: [{"id":"1","course_name":"Basic Excel 2013","course_desc":"Learn basic to intermediate functions of Excel. Simple formulas and features of Microsoft Excel 2013","course_days":"2 Days.","course_rating":"4.68"},{"id":"2","course_name":"Advanced Excel 2013","course_desc":"Learn Pivot Tables, VLookup, Macros & Advanced Functions of Excel.","course_days":"2 Days.","course_rating":"4.87"},{"id":"3","course_name":"Introduction to SQL","course_desc":"Learn to create a SQL database, query a database table and select, insert, update & delete records.","course_days":"2 Days.","course_rating":"4.89"},{"id":"4","course_name":"Facebook Marketing for Business","course_desc":"Learn to use Facebook for marketing your business on your own.","course_days":"1 Day","course_rating":"4.79"}]
** Activity (main) Pause, UserClosed = false **
** Activity (openfolder) Resume **
** Activity (openfolder) Pause, UserClosed = false **
** Activity (main) Resume **
Response from server: [{"id":"4","course_name":"Facebook Marketing for Business","course_desc":"Learn to use Facebook for marketing your business on your own.","course_days":"1 Day","course_rating":"4.79","course_prereq":"Must know basic PC skills, and must have a Facebook account.","course_outcomes":"Learn to use Facebook for business use. Understanding Posting, Events, Groups, Pages and make the best use of the most popular Social Media Marketing application.","course_comments":"","course_grant":"SDF, PIC & SkillsFuture"}]
main_jobdone (java line: 536)
java.lang.NumberFormatException: Invalid double: "null"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:269)
at java.lang.Double.parseDouble(Double.java:295)
at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:612)
at anywheresoftware.b4a.samples.mysql.main._jobdone(main.java:536)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NumberFormatException: Invalid double: "null"



line 38 is the main.executeremotequery
 
Upvote 0
Status
Not open for further replies.
Top