Re: Access Access vai odbc

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



That worked perfectly. Could you refer me to a resource that explains the
exact syntax of the connection string?
Thanks.

"Stefan Wuebbe" wrote:


"Lew" <Lew@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:E166103C-867C-4984-B33D-1822D6793CC8@xxxxxxxxxxxxxxxx
I have a vfp app that needs to do some io to an access mdb, I'm assuming
that
the easiest way do this is via odbc, if I'm correct can someone point me
to
some sample code or... is there a better method? The io is very simple..
locate a record in a table & change a single value.

Right, in your case ODBC might be the better way (than COM automation).

example.prg:

Set Step On
LOCAL llOK, lcErrorMessage
llOK = .T.
lcErrorMessage = ""

LOCAL lcMDB
IF m.llOK
lcMDB = GETFILE('mdb')
llOK = FILE(m.lcMDB,1)
lcErrorMessage = ""
ENDIF

LOCAL lcConnectionString, h
IF m.llOK
lcConnectionString = ;
"DRIVER=Microsoft Access Driver (*.mdb);" + ;
"DBQ=" + JUSTFNAME(m.lcMDB) + ";" + ;
"DefaultDir=" + JUSTPATH(m.lcMDB) + ";" + ;
"DriverId=25;FIL=MSAccess;MaxBufferSize=2048;PageTimeout=5"
h = SQLSTRINGCONNECT(m.lcConnectionString)
llOK = ( h > 0 )
lcErrorMessage = "Connection failed."
ENDIF

LOCAL n
IF m.llOK
n = SQLTABLES(h,'','temp')
llOK = ( n > 0 )
IF !m.llOK
lcErrorMessage = GetLastError()
ENDIF
ENDIF
IF m.llOK
BROWSE
ENDIF

LOCAL lcTable
IF m.llOK
lcTable = 'customers' && whatever your specs say
n = SQLEXEC(h,[Select * From ] + m.lcTable,'temp')
llOK = ( n > 0 )
IF !m.llOK
lcErrorMessage = GetLastError()
ENDIF
ENDIF
IF m.llOK
BROWSE
ENDIF


TRY
SQLDISCONNECT(h)
CATCH
ENDTRY
IF !m.llOK AND !EMPTY(m.lcErrorMessage)
MESSAGEBOX(m.lcErrorMessage,48)
ENDIF

RETURN


FUNCTION GetLastError()
LOCAL lcMessage, laError[1]
lcMessage = ""
AERROR(laError)
IF TYPE('laError[2]') = 'C'
lcMessage = laError[2]
ENDIF

RETURN m.lcMessage
ENDFUNC



hth
-Stefan



--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



.



Relevant Pages

  • Re: Access Access vai odbc
    ... in your case ODBC might be the better way. ... LOCAL llOK, lcErrorMessage ... LOCAL lcMessage, laError ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Access Access vai odbc
    ... If you set up a connection with SQLCONNECTyou can get the connection ... exact syntax of the connection string? ... LOCAL llOK, lcErrorMessage ... LOCAL lcMessage, laError ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Access Access vai odbc
    ... exact syntax of the connection string? ... HTH ... in your case ODBC might be the better way. ... LOCAL llOK, lcErrorMessage ...
    (microsoft.public.fox.programmer.exchange)