Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP interface to MYOB
Message
 
To
12/09/2006 19:34:39
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
01153174
Message ID:
01153204
Views:
21
>Hi,
>
>We have a Visual Foxpro 8 application that we sould like to use to update MYOB data using the MYOB ODBC driver. We have successfully created a DSN, connected to MYOB and retrieved data from MYOB.
>
>We have been unable to successfully write to any MYOB tables or to determine how to retrieve error and warning messages using Visual Foxpro.
>
>Are there any example progams for writing data using Visual Foxpro?
>
>The code we are using is as below:
>
>**** Set up MYOB connection string for read-write access
>thisform.r_cConnStr = ;
>"DSN=myob;" + ;
>"DRIVER_COMPLETION=DRIVER_NOPROMPT;" + ;
>"ACCESS_TYPE=READ_WRITE;" + ;
>"IDENTIFY_BY=CARD_ID;" + ;
>"INSERT_TYPE=REJECT_DUPLICATES;" + ;
>"SUPPRESS_WARNING=TRUE;"
>
>**** Make the connection
>thisform.r_nConnHandle = SQLSTRINGCONNECT(thisform.r_cConnStr ,.T.)
>IF thisform.r_nConnHandle <= 0
>= MESSAGEBOX('Error connecting to MYOB data source.', MB_ICONSTOP, 'MYOB Connection Error')
>RETURN .F.
>ENDIF
>lnRes = sqlsetprop(thisform.r_nConnHandle, 'DispLogin', 3) && Set ODBC login Never
>lnRes = sqlsetprop(thisform.r_nConnHandle, 'Asynchronous', .F.) && Results returned asynchronously
>lnRes = sqlsetprop(thisform.r_nConnHandle, 'BatchMode', .T.) && Result sets returned all at once
>
>WAIT WINDOW "Retrieving all MYOB cusomers..." nowait
>lnRes = SQLEXEC(thisform.r_nConnHandle, 'SELECT * FROM MYOB.customers', 'vCustomers')
>*
>*--- The above command succeeds and all Customers are returned
>*
>lcSql = "INSERT INTO Import_Consolidated_Taxcodes VALUES ('TST','','WET')"
>lnRes = SQLEXEC(thisform.r_nConnHandle, lcSQL)
>*
>*--- The above insert statement fails (lnRes = -1)
>*
>
>Any suggestions would be most gratefully received,
>
>TIA,
>
>Andrew Harper

One shot in the dark. I gues you have more than 3 fields in Import_Consolidated_Taxcodes table. If this is so you must use Field list when insert in that table. But as Fred said it is always a good idea to check the result of any of SPT commands and if it fail use AERROR() to get the ODBC error.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform