Search the Community
Showing results for tags 'accdb'.
-
I need to provide an example of a form showing query result from MS Access. Preferably Access 2007/2010 (accdb format) I have read several posts / UDFs but just can't seem to find the missing piece. This is what I have so far: ; register error handler for displaying errors Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $title,$adoCon,$dbname,$adoRs, $_output ; create connection $adoCon = ObjCreate("ADODB.Connection") $dbname = @ScriptDir & "\" & "Nwind2007.accdb" ; this is for Access 2007 / 2010 according to Microsoft $adoCon.Open ("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $dbname) ; create recordset $adoRs = ObjCreate ("ADODB.Recordset") $adoRs.CursorType = 1 $adoRs.LockType = 3 ; this query is copied from MS Access designer ; should return something $query = "SELECT * FROM Customers;" ; open query $adoRs.Open ($query, $adoCon) with $adoRs if .RecordCount then while not (.EOF) $_output = $_output & .Fields("Address").Value & @CRLF .MoveNext WEnd msgbox(0,"RC", .RecordCount & " records found..") endif EndWith $adoCon.Close MsgBox(0,"result",$_output) Func _ErrFunc($oError) if $oError <> "0" then MsgBox(0, "COM error", "err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) endif EndFunc ;==>_ErrFunc For the demo purpose I use the NorthWind database, converted to Access2007. I did install the MSAccess2007 componens from MicroSoft. The NorthWind database is available here: http://ge.tt/35lU43M/v/0 All seems to work, but I never have a .RecordCount property, so the with/endwith is not executed. All I need is a simple forking example, then I can roll with the ball. <rant> Why must MS Access be SO difficult to work with when SQLite or MySQL are piece of cake ? </rant>