strange error

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
vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

strange error

Post by vedus » Sun Dec 22, 2013 4:56 pm

i have a card with 23 fields
field names is ok the same as in the database table.
the strange is when i go to save a record i get the "datatype mismatch error"
when i go in the field "customer_id" and lock the text from the inspector the data is saved ok..without "datatype mismatch error"
there is no fields locked in the card,is clean for data enter..
Can anyone tell me where i do wrong?

code in the card

Code: Select all

on opencard
  set the useUnicode to true
   set the dontWrap of field customer_info to false
  set the visible of btn"save_thecustomer"  to false
  set the visible of btn"start1"  to false
  put empty into image "cPhoto"
  put empty into fld "customer_photo"

// empty the fields
if fld "customer_id" is empty then
  else
  repeat with x = 1 to number of fields
      if not the lockText of fld x then
          put empty into fld x
      end if
  end repeat
end if

#fill the data for option box
dbcolumns "first_name,last_name"
put dbGet("customers") into myRecords
repeat for each key tKey in myRecords
  put myRecords[tKey]["first_name"] && myRecords[tKey]["last_name"]& CR after tOptionMenuList
end repeat

## Delete trailing CR
delete char -1 of tOptionMenuList

## Fill option button for unicode text
set the unicodetext of btn "myopt" to uniencode(tOptionMenuList,"utf8")

end opencard
code in the save button

Code: Select all

on mouseUp
  # This command will look into the current card for fields, buttons and groups
# with the same name as the fields on a given database table. If it finds the correct controls
# it picks their values and assemble an array to be used by the database touching functions.
  put dbCardToArray("customers") into MyRecords
  
  //if no text into field
  put the text of fld "first_name" into mRec
  
  switch MyRecords
    
    case mRec
      if mRec is empty then
        set the backgroundcolor of fld "first_name" to "red"  
          answer "No Records" with "OK"
              wait 10 milliseconds
               set the backgroundcolor of fld "first_name" to "white"
      end if
      break
      
    case MyRecords
      if field "customer_id" is empty then
        //Insert the records into table
        get dbInsert ("customers",MyRecords)
        if it is a number then
          answer it &&  "New Record Saved"
        else
          answer error it
        end if
    end if
  end switch
end mouseUp

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: strange error

Post by Klaus » Sun Dec 22, 2013 5:50 pm

HI vedus,

no idea without debugging the whole thing, but this is definitively a SQL/database error.
Now you need to find out in which DB FIELD this error occurs and check its field definiton
in the database :D


Best

Klaus

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: strange error

Post by vedus » Sun Dec 22, 2013 5:54 pm

i
Klaus wrote:HI vedus,

no idea without debugging the whole thing, but this is definitively a SQL/database error.
Now you need to find out in which DB FIELD this error occurs and check its field definiton
in the database :D


Best

Klaus
hi klaus :)
i make the debugging in the sqlite and integrity check and is ok :(
the strange is 1 with the locktext in the field "customer_id" and the other is now i put the project in the simulator the save buttons is NO working :(
but in the desktop app is working ok :D
maybe the stack is corrupted?

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

Re: strange error

Post by SparkOut » Sun Dec 22, 2013 6:24 pm

vedus wrote:maybe the stack is corrupted?
Well it's not impossible, but I would think that very unlikely.
Much more likely is that the location of the database is not a valid place for mobile use. You need to use specialFolderPath and locate the database into a writeable place, ie "documents".
The rest of it needs more code to be able to see what your functions are doing. Specifically the part that creates the sql INSERT query.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: strange error

Post by jacque » Mon Dec 23, 2013 6:24 pm

There is something wrong with your save button script. The test for the switch structure appears to be an array, but it needs to be a string. Then, inside the switch construct, the case "myRecords" is the same array as the main switch statement parameter. If "myRecords" is really an array, I don't think the case statement that saves the data should ever run.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply