Access database

Windows specific questions.
Post Reply
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Access database

Post by phishguy »

Does anyone have an example on how to use Freebasic to enter data into a field on a Microsoft Access database? I pretty sure that Disphelper could do it, or possibly a ODBC wrapper. I have searched the forum and on the internet with no avail. The Disphelper site has a link for examples that is no longer working (it times out).

Thanks
dani.user
Posts: 284
Joined: Sep 30, 2006 10:41

Post by dani.user »

On the front page of the website you can see a link to "FB ODBC Library" and a library for using activex controls
ercolesptr
Posts: 2
Joined: Nov 25, 2022 15:17

Re: Access database

Post by ercolesptr »

I managed to use DAO to access MS Access database with disphelper as follows:

Code: Select all

'#CONSOLE ON
#Define UNICODE
#Include Once "windows.bi"
#define UNICODE
#include "disphelper/disphelper.bi"
DISPATCH_OBJ(objDBEngine)
DISPATCH_OBJ(objWORKSpace)
DISPATCH_OBJ(objDATABase)
DISPATCH_OBJ(objRECORDSet)

dhInitialize(TRUE)
dhToggleExceptions(TRUE)
dhCreateObject("DAO.DBEngine.36", NULL, @objDBEngine)
dhGetValue("%o",@objWORKSpace,objDBEngine,".Workspaces(%d)",0)
dhGetValue("%o",@objDATABase,objWORKSpace,".OpenDatabase(%s)","C:\Test.mdb")
dhGetValue("%o",@objRECORDSet,objDATABase,".OpenRecordset(%s,dbOpenDynaset)","SELECT * FROM Details")

Dim As zstring Ptr szResponse
Dim as boolean bEOF

do
dhGetValue("%b",@bEOF,objRECORDSet,".EOF")
if (bEOF) then exit do
dhGetValue("%s", @szResponse, objRECORDSet, ".Fields(%s)","Name")
Print "Response: "; *szResponse
dhCallMethod(objRECORDSet, ".MoveNext")
loop
dhFreeString(szResponse)

SAFE_RELEASE(objRECORDSet)
SAFE_RELEASE(objDATABase)
SAFE_RELEASE(objWORKSpace)
SAFE_RELEASE(objDBEngine)
dhUninitialize(TRUE)
Print
Print "Press any key..."
Sleep
Last edited by fxm on Nov 30, 2022 19:09, edited 1 time in total.
Reason: Added code tags.
Post Reply