Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL INSERT to MS Access Failing
Message
From
01/11/2011 07:11:19
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01527718
Message ID:
01527765
Views:
68
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)
Ray Roper
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform