Question : Writing a value from Visual Foxpro 9.0 to Pervasive SQL9.5  table

Want to write a value to a Pervasive SQL from Visual Foxpro 9.0.  Record already exist into Pervasive table, so no INSERT.  I'm not too familiar with Pervasive otherwise that it is SQL and Visual Foxpro is related to SQL (even if it is not exact SQL coding).  I was thinking of ODBC as first step...

Answer : Writing a value from Visual Foxpro 9.0 to Pervasive SQL9.5  table

If you have a Connection established you have a Connection Handle

Something like:

nConnectionHandle =

* --- Using SQL Passthru approach ---
cSQLCommand = "SELECT * From PTable WHERE Record_ID = 1"
nRet = SQLEXEC(nConnectionHandle, cSQLCommand, 'Result')
IF nRet = 1
  SELECT Result
  < whatever >
ENDIF

or something like:
cSQLCommand = "UPDATE PTable SET MyField = "MyName" WHERE Record_ID = 1"
nRet = SQLEXEC(nConnectionHandle, cSQLCommand)
IF nRet = 1
  < Update Executed >
 ENDIF

* --- Disconnect From Connection ---
=SQLDisconnect(nConnectionHandle)

NOTE - The above examples are pretty simplistic and do not go into Error Handling should something fail.

Remember that you have to have the SQL Command Syntax be what the backend server wants to see - not just what VFP might be able to use.

You can always test your syntax by executing it directly within the SQL Server interface to see if it 'likes it'.

Good Luck


Random Solutions  
 
programming4us programming4us