Page 1 of 1

Database Query HELP

Posted: Fri Feb 24, 2017 7:09 pm
by Gunit31
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)"

Re: Database Query HELP

Posted: Fri Feb 24, 2017 8:17 pm
by AxWald
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!