Hi All
I have the following code working - connecting to a MYOB ( accounting software)
but I would like to add a record to the table.
#include "fivewin.ch"
function main()
local cStr,oCon,oRecSet,oRs,cn,nCnt := 0
cStr := "Driver={MYOAU0901}; TYPE=MYOB; UID=Administrator; PWD=;DATABASE=C:\Premier125\Clearwtr.myo; HOST_EXE_PATH=C:\Premier125\MYOBP.exe;NETWORK_PROTOCOL=NONET; DRIVER_COMPLETION=DRIVER_NOPROMPT"
if oCon == nil
oCon := TOleAuto():new("ADODB.Connection")
oCon:ConnectionString := cStr
TRY
oCon:Open()
lConnect := .t.
CATCH
oCon := nil
MsgInfo('Connect Fail')
return nil
END
else
lConnect := .t.
endif
if oCon != nil .and. oRs == nil
oRs := TOleAuto():new( "ADODB.RecordSet" )
oRs:ActiveConnection := oCon
oRs:Source := "select * from Cards"
oRs:LockType := 4 // adLockOptimistic
oRs:CursorLocation := 3 //adUseClient
oRs:CacheSize := 100
TRY
oRs:Open()
CATCH
MsgInfo('Table Open Failure')
return nil
END
endif
if oRs:RecordCount() > 0
do while ! oRs:eof()
MsgInfo(oRs:Fields( "LastName" ):Value )
oRs:MoveNext()
enddo
SysRefresh()
endif
return(nil)