Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange Error Message
Message
De
25/03/2011 18:26:05
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01504918
Message ID:
01505031
Vues:
40
It's not surprising that you're missing something. I made a mistake when I created the example. It should have been
lcSql = "UPDATE myTable SET myField = ?myValue WHERE pk = ?mypk"

IF oDataClass.prepare(tnConnection,lcSql)
  ** tnConnection is a valid, pre-existing connection to an ODBC datasource
  SCAN
    mypk = table.pk
    myvalue = table.value
    IF NOT oDataClass.sql_execute(tnConnection)  
        ** this is the line that was wrong in the example.  
        ** You don't pass the SQL when executing a  prepared statement
     ** Error Handling Code
    ENDIF
  ENDSCAN
ELSE
  ** Error Handling Code
ENDIF

***oDataClass.prepare
LPARAMETERS tnConnection,tcSql
=SQLPREPARE(tnConnection,tcSql)
** With appropriate error handling
"Is parameter tcSql supposed to be lcSql?"

If you mean have I used the wrong name then no. Each use of lcSql and tcSql is intentional.

>>>Rich,
>>>
>>>
>>>* Your code:
>>>IF EMPTY(tcSql)  && Processing via an SQLPREPARE() statement
>>>	tcSql = " "   && So Error Routine has character value
>>>	lnResult = SQLEXEC(tnConnection)                                 &&     ?????
>>>
>>>
>>>What does it mean? What is exatly tnConnection? And what is your sqlprepare line looks like?
>>
>>From the help:
>>"SQLPREPARE( ) sends the SQL statement to the data source where it is compiled for faster execution. After the SQL statement is compiled, it can be executed with SQLEXEC( ). If SQLEXEC( ) is used to execute a SQL statement prepared with SQLPREPARE( ), only the statement handle is required in SQLEXEC( )."
>>
>>
>>In my case it could be something like
>>lcSql = "UPDATE myTable SET myField = ?myValue WHERE pk = ?mypk"
>>IF oDataClass.prepare(tnConnection,lcSql)
>>  SCAN
>>    mypk = table.pk
>>    myvalue = table.value
>>    IF NOT oDataClass.sql_execute(tnConnection,lcSql)
>>      ** Error Handling Code
>>    ENDIF
>>  ENDSCAN
>>ELSE
>>  ** Error Handling Code
>>ENDIF
>>
>>***oDataClass.prepare
>>LPARAMETERS tnConnection,tcSql
>>=SQLPREPARE(tnConnection,tcSql)
>>** With appropriate error handling
>>
>
>
>Probably I still missing something. So, just in case:
>You have prepared statement with valid not empty lcSQL. Is parameter tcSql supposed to be lcSql?
>If so, is it possible that for some reason tcSql appeared empty instead of expected lcSql ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform