Database Query HELP

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
Gunit31
Posts: 4
Joined: Tue Feb 14, 2017 7:05 pm

Database Query HELP

Post by Gunit31 » Fri Feb 24, 2017 7:09 pm

My query system was fine before but then I added 3 tables to draw from(Student, Administrator, Instructor) and now every time I try to execute it I get an answer of "revdberr,Database Error: no such table: Administrator" which does't make sense. The solution seems to be staring me in the face but I don't see it. Please help.


on Login
local tPasswordcheck, tPassword
put field "Username" into tUsername
//put "SELECT Password FROM Login WHERE Username = tUsername" into tSQLQuery
if the backgroundColor of graphic "tcolor" is (0,255,0) then
put "SELECT Password FROM Student WHERE Username = '" & tUsername & "'" into tSQLQuery
else
if the backgroundColor of graphic "tcolor" is (0,0,255) then
put "SELECT Password FROM Instructor WHERE Username = '" & tUsername & "'" into tSQLQuery
else
if the backgroundColor of graphic "tcolor" is (255,0,0) then
put "SELECT Password FROM Administrator WHERE Username = '" & tUsername & "'" into tSQLQuery
end if
end if
end if
put revDataFromQuery( tab, return, gConnectionID, tSQLQuery) into field "Password(check)"

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Database Query HELP

Post by AxWald » Fri Feb 24, 2017 8:17 pm

Hi,

you're sure you have a valid gConnectionID?

If yes & it's a SQLite, try with the full db path in the databaseName parameter. I remember situations where I got a valid ConnID + still "no such table": I had used relative paths ...
And I managed already to mess up a path variable, resulting in creating an empty SQLite and querying this one ...

You may also try to write tableNames as `tableName` (numtochar(96), accent grave). I know at least one MySQL that chokes if I don't, so I made it a habit.

The code looks okay, besides that you'll burn in hell forever, unfortunately:
"You shall never store unhashed passwords in a database. Or suffer for it!"

Hope this helps. Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply