Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
hsh_636
- Posts: 31
- Joined: Sun Mar 02, 2014 5:15 pm
Post
by hsh_636 » Fri May 02, 2014 4:40 pm
Hello everyone, I`m trying to design a registration and login page that will log users to the application based on if they have entry in the sqlite database the problem is it works fine when I run it on my desktop but when I deploy it to the android emulator and I have already ticked the sqlite external option before doing so it gives me the following error "revdberr, Database error: no such table" although the table exists and it works fine when I compile it on my desktop.
this the code I`m using to connect to my sqlite database
Code: Select all
on mouseUp
global gSession
-- check the global connection ID to make sure we have a database connection
global gConnectionID
-- set up the connection parameters - edit these to suit your database
put specialFolderPath("documents") & "/HSH_636.sqlite" into tDatabasePath
-- connect to the database
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tResult
-- check if it worked and display an error message if it didn't
-- & set the connection ID global
if tResult is a number then
put tResult into gConnectionID
answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
put "SELECT * from account" into tSQLDatom
put revDataFromQuery(tab, cr, gConnectionID, tSQLDatom) into tDatom
put tDatom into field "accountDetails"
end mouseUp
So if anybody can tell me what`s problem and how I can fix it, thanks.
-
sefrojones
- Livecode Opensource Backer

- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Post
by sefrojones » Fri May 02, 2014 5:31 pm
Generally in my experience, when something works on desktop, but not android when it theoretically should, it is usually a permissions issue. This is not always the case, just something I've noticed with my android projects. That being said, wouldn't using a MySQL database be more suited for holding and verifying login credentials?
--Sefro
edit: the Cloud and Database Academy has a great 4 part lesson about creating login systems:
https://livecode.com/store/training/liv ... d-academy/
-
hsh_636
- Posts: 31
- Joined: Sun Mar 02, 2014 5:15 pm
Post
by hsh_636 » Fri May 02, 2014 7:34 pm
I would use mysql workbench if I didnt have a problem with creating foreign keys constraint and you mean by credentials in which side and what can I do about it any advice will be helpful.
-
sefrojones
- Livecode Opensource Backer

- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Post
by sefrojones » Fri May 02, 2014 8:33 pm
I'm not too sure what your problem could be. I just tested the stack created in this lesson, and it seems to be working okay in my android emulator.
http://lessons.runrev.com/s/lessons/m/4 ... e-database
I've attached the copy of the stack from that lesson that worked when tested on Android. The only things I changed were button sizes and text formatting, as well as set the fullscreenmode in the preopenstack handler.
Would it be possible for you to post your stack?
--Sefro
Edit: Are you sure the table exists?
-
Attachments
-
- SQLite Example.zip
- (2.11 KiB) Downloaded 240 times
-
sefrojones
- Livecode Opensource Backer

- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Post
by sefrojones » Fri May 02, 2014 8:50 pm
The reason I suggested MySQL was that using an SQLite database saved to the specialfolderpath("documents") will only be available to that device. So if your user were to try to log into the app on a different device they would have to re-register. Using an online MySQL database would allow them to log in from any device that was running the app. At least that is my understanding. If I am wrong, I'm sure one of the more experienced livecode veterans will speak up
Hopefully some of this helps you!
Good Luck,
Sefro
-
hsh_636
- Posts: 31
- Joined: Sun Mar 02, 2014 5:15 pm
Post
by hsh_636 » Fri May 02, 2014 8:55 pm
I'm positive that the table is there you should try the button below the login button the problem is that it can't retrieve data from the database when I'm using the emulator but works fine on my computer, also can you suggest what is the best data storage I can use to store and retrieve data remotely from my app also can you tell me how can I get started with the online my sql database, thanks your help is appreciated
-
sefrojones
- Livecode Opensource Backer

- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Post
by sefrojones » Fri May 02, 2014 9:07 pm
Just because the table is there on your PC, the same table will not be on the android emulator unless you create it again. The specialfolderpath("documents") is a local folder so each time you install the app, you must create the database and table on that device, and it will only be available to that device. This is why I suggested an online MySQL database instead. Using a MySQL database you will also be able to remotely store and retrieve data from your app. Here is a link on how to connect to a MySQL Database:
http://lessons.runrev.com/s/lessons/m/4 ... l-database
Now, setting up your own MySQl database is a little bit more involved, and requires a server. But there are plenty of places that offer MySQL databases as a service. For experimentation sake, you can use the service in the link below to set up a free 5mb MySQL database.
http://www.freesqldatabase.com/
--Sefro
-
hsh_636
- Posts: 31
- Joined: Sun Mar 02, 2014 5:15 pm
Post
by hsh_636 » Fri May 02, 2014 9:12 pm
Thanks a lot Sir for your help, and if it's okay with you I will return to ask you if I had any further questions about online my sql databases or connecting to them.
-
sefrojones
- Livecode Opensource Backer

- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Post
by sefrojones » Fri May 02, 2014 9:22 pm
That's no problem with me! I hope some of this info helps. I am still learning new things about Livecode almost every day, so I probably won't always have the *best* answer. But this forum is chock full of livecode experts who are willing to help, so I'm sure you'll be able to work it out in no time!
Good Luck!
--Sefro
-
hsh_636
- Posts: 31
- Joined: Sun Mar 02, 2014 5:15 pm
Post
by hsh_636 » Mon May 05, 2014 8:33 am
Hello, I tried using the mysql server in a hosting website and everything is working fine on both the iOS simulator and the android emulator, the only problem that I have is when I try to connect to the mysql server via live code, but it connects perfectly when I connect via phpmyadmin while connecting to my university's network it gives me the following error can't connect to MySql server 'Host Name', I never faced this problem while I was connecting to my home network, so I guess the problem is in my university's network can you suggest to me what may be the cause of such an error?