I will never get famous for writing nice code !!
But I definitely get there, because of the nice intro's I make
How much more minimalistic can we get !!
Creating a Database and not having to use a DB file or an ODBC, or DNS less connection, or Queries.
This means there is no dependency on any external DLL's or what so ever.
I have used the technique of a Disconnected Recordset.
For those who don' t know what I mean :
Two of the most exciting features of ActiveX Data Objects (ADO) are disconnected recordsets
and saved recordsets. Disconnected recordsets allow you to work with a recordset that is no longer connected to a data source.
A saved recordset is saved to a file that can be closed and reopened without an active connection.
You should use a disconnected recordset when the application needs to drop a connection to the
data source and still retain the ability to view or manipulate the data.
A saved or persisted recordset is data that is saved to a file. You can close and reopen the file
later without an active connection. For example, an application may need to download data to a laptop computer that updates the data while disconnected from the network. When you reconnect the
laptop to the network, the application then updates the shared network database with the additions
and changes that have been made.
#include <GUIConstants.au3> #include <GuiListView.au3> Dim $oMyError, $ador Local $listview, $Items, $item1, $item2 Const $adVarChar = 200 Const $MaxCharacters = 255 Const $field1 = "Name" Const $Field2 = "Memo" ; Initializes COM handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $ador = ObjCreate( "ADOR.Recordset" ) ; Create a disconnected ADOR Object with the Beta version With $ador .Fields.append ($field1, $adVarChar, $MaxCharacters) .Fields.append ($Field2, $adVarChar, $MaxCharacters) ;.CursorType = "adOpenDynamic" ;.CursorLocation = "AdUseClient" .Open EndWith GUICreate("No ODBC no DNS no DB no Query 1.0", 600, 400, (@DesktopWidth/2)-300, _ (@DesktopHeight/2)-350, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $listview = GUICtrlCreateListView ("Names |Comments ",10,10,200,350) $btn_1 = GUICtrlCreateButton ("Build the DB", 10, 365, 110, 20) $btn_2 = GUICtrlCreateButton ("Refresh", 130, 365, 110, 20) GUISetState() With $ador .AddNew .Fields(0).Value = "AutoIT" $item1= .Fields(0).Value .Fields(1).Value = "Isn't it great !!" $item2= .Fields(1).Value $items=GUICtrlCreateListViewItem($item1&"|"&$item2,$listview) .AddNew .Fields(0).Value = "ptrex" $item1= .Fields(0).Value .Fields(1).Value = "Or am I great ?" $item2= .Fields(1).Value $items=GUICtrlCreateListViewItem($item1&"|"&$item2,$listview) EndWith While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn_1 _Build_DB() Case $msg = $btn_2 _Refresh() EndSelect WEnd Exit Func _Build_DB () If not IsObj($ador) Then MsgBox(0,"Error","Cannot create Object") EndIf With $ador For $i = 0 To 49 .AddNew .Fields(0).Value = "Name" & $i+1 $item1= .Fields(0).Value .Fields(1).Value = "Added some more" $item2= .Fields(1).Value $items=GUICtrlCreateListViewItem($item1&"|"&$item2,$listview) Next EndWith EndFunc Func _Refresh() _GUICtrlListViewDeleteAllItems ($listview) _Build_DB() EndFunc ; This is Sven P's custom error handler added by ptrex Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc
ADOR_example.au3 6.81K
391 downloadsAnd for those who thought who that DNS less connections was the ultimate
Enjoy !!
Edited by ptrex, 14 September 2012 - 09:38 AM.





