SQL Statement

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Quinton B.
Posts: 104
Joined: Mon Mar 20, 2017 5:13 am

SQL Statement

Post by Quinton B. » Mon Jun 24, 2019 2:27 am

No data seems to be inserted into the database, whats wrong?

Code: Select all

put the text of graphic "The_Image" into tImageCheck
   put "tImageCheck, tUserNameCheck, tPasswordCheck, tDoDEmailCheck, tDSNCheck, tPersonellNumberCheck, tAddressCheck, tSecurityQuestion1, tSecurityAnswer1, tSecurityQuestion2, tSecurityAnswer2, tSecurityQuestion3, tSecurityAnswer3, tBranchCheck, tBaseCheck, tOperationsGroupCheck, tSquadronCheck, tFlightCheck, tRankCheck, tRandomAlphaNumericalGenerator" into tALLFIELDS
   --put tImageCheck, tUserNameCheck, tPasswordCheck, tDoDEmailCheck, tDSNCheck, tPersonellNumberCheck, tAddressCheck, tSecurityQuestion1, tSecurityAnswer1, tSecurityQuestion2, tSecurityAnswer2, tSecurityQuestion3, tSecurityAnswer3, tBranchCheck, tBaseCheck, tOperationsGroupCheck, tSquadronCheck, tFlightCheck, tRankCheck, tRandomAlphaNumericalGenerator into tALLFIELDS
   put "xxx" into tBA
   put "xxx" into tDBN
   put "xxx" into tDBU
   put "xxx" into tDBP
   put revOpenDatabase("mysql", tBA, tDBN, tDBU, tDBP) into lLogin
   put lLogin into gConnectionID
   if lLogin is a number then
      put "INSERT INTO PAV2_ACCOUNTS (" & tALLFIELDS & ") VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20)" into lSQL
      -------------------------------
      --THE BELLOW LINE COULD FUCK UP
      -------------------------------
      revExecuteSQL gConnectionID, lSQL, "tImageCheck", "tUserNameCheck", "tPasswordCheck", "tDoDEmailCheck", "tDSNCheck", "tPersonellNumberCheck", "tAddressCheck", "tSecurityQuestion1", "tSecurityAnswer1", "tSecurityQuestion2", "tSecurityAnswer2", "tSecurityQuestion3", "tSecurityAnswer3", "tBranchCheck", "tBaseCheck", "tOperationsGroupCheck", "tSquadronCheck", "tFlightCheck", "tRankCheck", "tRandomAlphaNumericalGenerator"
      if item 1 of tData = "revdberr" then
         answer error "There was a problem querying the database:" & cr & tData
      else
         RegisterResetCard
         SendTheEmail
         go to card "Login"
      end if
   end if
   revCloseDatabase gConnectionID
end ClearAndVerify

SparkOut
Posts: 1984
Joined: Sun Sep 23, 2007 4:58 pm

Re: SQL Statement

Post by SparkOut » Mon Jun 24, 2019 7:54 am

First question, are the database column names really the same as the variable names? I mean in the database structure do you really have columns called 'tUserNameCheck' and 'tImageCheck'?

Quinton B.
Posts: 104
Joined: Mon Mar 20, 2017 5:13 am

Re: SQL Statement

Post by Quinton B. » Mon Jun 24, 2019 6:34 pm

No, lol, I think you might have helped me, but from which portion should the database coulmn names be after put the text of graphic etc, etc. Or at the revExecuteSQL line.

SparkOut
Posts: 1984
Joined: Sun Sep 23, 2007 4:58 pm

Re: SQL Statement

Post by SparkOut » Mon Jun 24, 2019 9:40 pm

In the second line of the code example above put the real database column names into tALLFIELDS

Then we can see what else nweds to be addressed

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 829
Joined: Fri Aug 15, 2008 7:15 am

Re: SQL Statement

Post by bangkok » Tue Jun 25, 2019 7:38 am

It's becoming a real trend.

All newbies got lost with the "variablesList" and "arrayName" forms, for revExecuteSQL and revQueryDatabase commands (look in the forum...)

Just don't do it !

Use the classic form, which you can read, which you can "see".

If you can not "see" (read) a SQL statement, then you're blind. And then you make mistakes. Inevitably.

The "classic" form is :

Code: Select all

put "Hello World" into tMyVar
put "update mytable set myvar='"&tMyVar&&"' where myindex=1" into tSQL
answer tSQL
revExecuteSQL gConnectionID, tSQL

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”