Please help, Code runs on windows app but not Android

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Jannie
Posts: 10
Joined: Sun May 17, 2015 5:27 am

Please help, Code runs on windows app but not Android

Post by Jannie » Wed Oct 28, 2015 1:31 pm

Hi all

Please help i am really getting frustrated. The following code runs fine if i create a standalone app for windows.I have one card with a image and a button on it.

When i create a standalone for Android however the button shows but if you touch it just seems to do nothing. The answer gothedata in the get_databse-data command never displays so it seems the code is not getting there, what am i doing wrong.

please help.

---------------------------------------------------------------------------------------
on mouseUp
get_database_data

end mouseUp

command get_database_data

global gConnectionID, gDetailList
put revOpenDatabase( "ODBC" ,"DRIVER=SQL Server;SERVER=197.81.192.75;DATABASE=mypotsedeksel;UID=######;PWD=#######;Trusted_Connection=No",,,) into gConnectionID
put "SELECT UserName, PicturePath as MyPicture from [user] Where UserID <200 and PicturePath <> 'PhotoNotProvided.gif' ; " into tDetails

put revQueryDatabase( gConnectionID, tDetails) into gDetailList
answer gotthedata
ConvertSQLCursorToArray gDetailList, theDataGridArray
revCloseCursor gDetailList
revCloseDatabase gConnectionID

end get_database_data

command ConvertSQLCursorToArray pCursor, @pOutArrayA
local i
local theFields
local theError

## Get the names of all the columns in the database cursor
put revDatabaseColumnNames(pCursor) into theFields
if theFields begins with "revdberr," then
put item 2 to -1 of theFields into theError
end if

if theError is empty then

put 0 into i

## Loop through all rows in cursor
repeat until revQueryIsAtEnd(pCursor)
add 1 to i


## Move all fields in row into next dimension of the array
repeat for each item theField in theFields
answer inloop
if theField = "MyPicture" Then
clone image "Image1"
set the name of the last image to ("Image" & i+1 )
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
set the filename of the last image to "directory on my webserver" &pOutArrayA[ theField ]
set the loc of last image to random (10 ), random (10 )

set the visible of the last image to true
answer filename of the last image

else
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
end if

end repeat


revMoveToNextRecord pCursor
end repeat


end if

return theError
end ConvertSQLCursorToArray

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Please help, Code runs on windows app but not Android

Post by LCNeil » Wed Oct 28, 2015 1:39 pm

Hi Jannie,

ODBC is not supported on mobile...yet

The database types that are directly supported on mobile are MySQL and SQLite.

A possible alternative is to use a webservice for communication with your DB (PHP/ LC server etc). You could then make web calls to this service from your mobile app.

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Please help, Code runs on windows app but not Android

Post by Klaus » Wed Oct 28, 2015 1:45 pm

Hi Jannie,

1. please use the CODE tags (at the top of the entry text fiedl here) to make pasted LC code better readable.
Like this:

Code: Select all

on mouseup
   do_this_and_that
end mouseup
2. You should do some errorchecking, obviously there is a problem to connect to the db already.
Add this line and tell us what you see:
...
put revOpenDatabase( "ODBC" ,"...=No",,,) into gConnectionID
answer gConnectionID
...
You should see a NUMBER when the connection is made and maybe a hint what does not work if not.


Best

Klaus

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Please help, Code runs on windows app but not Android

Post by Klaus » Wed Oct 28, 2015 1:47 pm

LCNeil wrote:ODBC is not supported on mobile...yet
Oh, that was my first guess, but then I checked the dictionary and did not find any hint about this! :(

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Please help, Code runs on windows app but not Android

Post by LCNeil » Wed Oct 28, 2015 2:00 pm

Yes, recent docs are missing this information. I've added a comment to the revOpenDatabase dictionary entry which should show up after its been approved :)

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Please help, Code runs on windows app but not Android

Post by Klaus » Wed Oct 28, 2015 2:18 pm

Great, thanks! :D

Jannie
Posts: 10
Joined: Sun May 17, 2015 5:27 am

Re: Please help, Code runs on windows app but not Android

Post by Jannie » Thu Oct 29, 2015 6:44 am

Thanks Klaus

I will use MySql instead of SQL server.
Any idea when ODBC will be supported?

Regards

Post Reply