Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL INSERT to MS Access Failing
Message
 
 
À
01/11/2011 07:11:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01527718
Message ID:
01527768
Vues:
62
Unfortunately, OUTPUT clause is for SQL Server, not for Access. In Access there is no SCOPE_IDENTITY() or OUTPUT clause.

>Naomi, I have been unable to find any examples of proper syntax for using the OUTPUT clause from VFP with an Access database. I've tried the following code snippet with about a dozen different variations, bracketing table and field names, different order of clauses, and so forth. My results every time were an error message: "Connectivity error: {Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT','PROCEDURE','SELECT', or 'UPDATE'."
>
>
>lcSourceFile = "C:\projects\\FRS\FRS5Data.accdb" 
>pnConnHandle = SQLSTRINGCONNECT("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + ; 
>   					  				  lcSourceFile) 
>TEXT TO lcSQLCommand NOSHOW 
>DECLARE @MyTable table( id INTEGER, myvalue varchar(10) );
>
>INSERT INTO [TblHousehold] (SYSTEMPROGRAMCD, PROGRAMCD,LSTUPDTDTTM) VALUES (?m.sysprogcd,?m.programcd,?m.lstupdtdttm) && values populated by SCATTER
>OUTPUT INSERTED.HouseholdSeqNbr, INSERTED.householdversionnbr INTO @myTable
>
>SELECT * FROM @myTable
>ENDTEXT
>
>lnResult = SQLEXEC(pnConnHandle,lcSQLCommand)
>
>IF lnResult <= 0
>	AERROR(laError)
>	MessageBox(laError[1,2])
>ENDIF 
>
>
>On the other hand, this works, so the basic concept is ok, just the OUTPUT syntax be foober.
>
>lcSourceFile = "C:\projects\FRS\FRS5Data.accdb" 
>pnConnHandle = SQLSTRINGCONNECT("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + ;
>   					  				  lcSourceFile)
>TEXT TO lcSQLCommand NOSHOW
>INSERT INTO [TblHousehold] (SYSTEMPROGRAMCD, PROGRAMCD,LSTUPDTDTTM) VALUES (?m.sysprogcd,?m.programcd,?m.lstupdtdttm)
>ENDTEXT
>
>lnResult = SQLEXEC(pnConnHandle,lcSQLCommand)
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform