Please help, Code runs on windows app but not Android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Please help, Code runs on windows app but not Android
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
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
Re: Please help, Code runs on windows app but not Android
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
--
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
--
Re: Please help, Code runs on windows app but not Android
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:
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
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
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
Re: Please help, Code runs on windows app but not Android
Oh, that was my first guess, but then I checked the dictionary and did not find any hint about this!LCNeil wrote:ODBC is not supported on mobile...yet

Re: Please help, Code runs on windows app but not Android
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
--

Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
Re: Please help, Code runs on windows app but not Android
Great, thanks! 

Re: Please help, Code runs on windows app but not Android
Thanks Klaus
I will use MySql instead of SQL server.
Any idea when ODBC will be supported?
Regards
I will use MySql instead of SQL server.
Any idea when ODBC will be supported?
Regards