Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLEXEC won't Insert data
Message
De
05/01/2008 12:18:28
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/01/2008 12:09:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01279605
Message ID:
01279607
Vues:
17
>I'm learning how to use SQLEXEC and have run into the following problem.
>
>Use localFoxproTable
>Scan
>lnsuccess = SQLEXEC(gnConnHandle, "INSERT INTO Sync_Box (field1) values (localFoxproTable.field1)")
>Endscan
>
>My handle is good but lnsuccess is -1
>
>Both fieldtypes are numeric.
>
>What am I doing wrong? Thanks in advance.
Use localFoxproTable
Scan
 lnsuccess = SQLEXEC(gnConnHandle, ;
   "INSERT INTO Sync_Box (field1) values (?localFoxproTable.field1)")
 if m.lnSuccess < 0
   ExplainError()
  endif
Endscan

Function ExplainError
LPARAMETERS tcSQL
tcSQL = EVL(m.tcSQL,'')
LOCAL ARRAY arrCheck[1]
LOCAL lcError,ix
Aerror(arrCheck)
lcError = "SQL:"+m.tcSQL+chr(13)
For ix=1 to 7
  lcError = m.lcError+trans( arrCheck [m.ix])+ chr(13)
Endfor
Messagebox(m.lcError,0,'Error definition')
PS: ? before localFoxproTable.field1 to mean that it's a parameter. Otherwise that insert command would seek for localFoxproTable.field1 at backend (and unlikely to find something there that matches, if by chance there is a match then you'd be unintentionally inserting wrong values).

aerror() to check why it failed. There maybe a series of reasons and the most common one is that the fields that are not supplied do not accept nulls and have no default value set.

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform