Re: Access Access vai odbc
- From: Lew <Lew@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Feb 2008 10:27:03 -0800
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
-----------------------------------------------------------
- Follow-Ups:
- Re: Access Access vai odbc
- From: Anders Altberg
- Re: Access Access vai odbc
- From: Jan Bucek
- Re: Access Access vai odbc
- References:
- Re: Access Access vai odbc
- From: Stefan Wuebbe
- Re: Access Access vai odbc
- Prev by Date: Re: I Hate this kind of problem. Please Help
- Next by Date: Re: I Hate this kind of problem. Please Help
- Previous by thread: Re: Access Access vai odbc
- Next by thread: Re: Access Access vai odbc
- Index(es):
Relevant Pages
|