Jump to content

ADO.au3 UDF 2.1.15 BETA

   (1 review)

1 Screenshot

About This File

I want to present BETA Version of my ADO.au3 UDF.

Support topic is here: http://www.autoitscript.com/forum/index.php?showtopic=180850

 

This UDF is modifed version of _sql.au3 UDF.

For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH

 

 


What's New in Version 2.1.15 BETA

Released

2017/05/28 '2.1.15 BETA'
.   Fixed: Function: __ADO_Recordset_IsNotEmpty() - mLipok
.       Thanks to @Skysnake for reporting
.   Added: many description to functions - mLipok
.   Added: many description to functions - thanks to Skysnake
.   Refactored: _ADO_Recordset_Display - mLipok
.   Changed: __ADO_Command_IsValid() - return values are now boolean - mLipok
.   Changed: __ADO_Connection_IsReady() - return values are now boolean - mLipok
.   Changed: __ADO_Connection_IsValid() - return values are now boolean - mLipok
.   Changed: __ADO_IsValidObjectType() - return values are now boolean - mLipok
.   Changed: __ADO_Recordset_IsNotEmpty() - return values are now boolean - mLipok
.   Changed: __ADO_Recordset_IsReady() - return values are now boolean - mLipok
.   Changed: __ADO_Recordset_IsValid() - return values are now boolean - mLipok
.   Changed: __ADO_RecordsetArray_IsValid() - return values are now boolean - mLipok
.
.
2017/03/20 '2.1.14 BETA'
.   Changed: Function: _ADO_COMErrorHandler - If @Compiled Then Return ....... - mLipok
.   Examples: Fixed bug in example for XLS - mLipok
.       thanks to ViciousXUSMC
.       https://www.autoitscript.com/forum/topic/180850-adoau3-udf-beta-support-topic/?do=findComment&comment=1307690
.   Examples: New Function: _ErrFunc($oError) - mLipok
.       ; HowTo: use your own COMErrorHandler instead internal ADO.au3 UDF COMError Handler - _ADO_COMErrorHandler
.   Examples: New Function: _ErrDescription($sDescription = Default) - mLipok
.       ; store description to use it outsided UDF in your own function
.   Added: #Au3Stripper_Ignore_Funcs=__ADO_EVENT__*  - mLipok
.   Changed: _ADO_Execute automaticaly check __ADO_Recordset_IsNotEmpty($oRecordset) - mLipok
.   Changed: Function: _ADO_ConnectionString_Access() - added support for '.accdb' when $sDriver = Default - mLipok
.   Chnaged: $aRocordset >> $aRecordset - Skysnake
.
.
.   !!! REMARK - I'm not sure when this following changes was happend
.   Removed: Function: _ADO_OpenSchema_Views - MS SQL: Object or provider could not perform requested action - mLipok
.       REF: https://msdn.microsoft.com/en-US/library/ee275169(v=bts.10).aspx
.           For all DBMS only this four QueryType are common:
.               adSchemaColumns, adSchemaIndexes, adSchemaTables, adSchemaProviderTypes
.           The SchemaEnum values supported by the Microsoft® OLE DB Provider for DB2 and the Microsoft® ODBC Driver for DB2 can be one of the following constants:
.               adSchemaColumns, adSchemaIndexes, adSchemaTables, adSchemaProviderTypes + adSchemaProcedures + adSchemaProcedureParameters + adSchemaPrimaryKeys
.   Removed: Function: _ADO_Schema_GetAllViews - as _ADO_OpenSchema_Views() is also removed - mLipok
.   Changed: Function: __ADO_IsValidObjectType - in case of @error occured, @extended always return $ADO_EXT_INTERNALFUNCTION - mLipok
.   Changed: Function: _ADO_COMErrorHandler() - parameter $oADO_Error is now passed as ByRef - mLipok
.   Added: Function INDEX - Skysnake

2016/03/18 '2.1.13 BETA'
.   Changed: _ADO_COMErrorHandler - now showing also _ADO_UDFVersion()  - mLipok
.   New: Enums: $ADO_ERR_ISNOTREADYOBJECT - mLipok
.   Renamed: Function: __ADO_Connection_IsOpen >> __ADO_Connection_IsReady - mLipok
.   Changed: Function: __ADO_Connection_IsReady : new feature checking connection state and seting  $ADO_ERR_ISNOTREADYOBJECT - mLipok
.   New: Function: __ADO_Recordset_IsReady - mLipok
.           __ADO_Recordset_IsReady is a wrapper for __ADO_Recordset_IsValid
.               which also check for $oRecordset.state and set $ADO_ERR_ISNOTREADYOBJECT
.           __ADO_Recordset_IsReady is now used in few functions which uses $oRecordset
.   Changed: Function: __ADO_Recordset_IsNotEmpty : now using __ADO_Recordset_IsReady instead __ADO_Recordset_IsValid - mLipok
.           as __ADO_Recordset_IsReady is wrapper for __ADO_Recordset_IsValid
.           so now __ADO_Recordset_IsNotEmpty checking old and new feature
.
.   !!!!!!!!!!!!!!!!!!!!!!!!
.   Renamed: _ADO_ERROR_Description >> _ADO_MSDNErrorValueEnum_Description
.   New: Function: _ADO_GetErrorDescription - mLipok
.   New: Function: _ADO_ConsoleError - mLipok

2016/03/09 '2.1.12 BETA'
.   New: Enums: $ADO_ERR_ISCLOSEDOBJECT - mLipok
.   New: Function: __ADO_Connection_IsOpen - mLipok
.           __ADO_Connection_IsOpen is a wrapper for __ADO_Connection_IsValid  which also check for $oConnection.state and set $ADO_ERR_ISCLOSEDOBJECT
.           __ADO_Connection_IsOpen is now used in few functions which uses $oConnection
.   Changed: Function: __ADO_Recordset_IsNotEmpty - checking $oRecordset.state and return $ADO_ERR_ISCLOSEDOBJECT - mLipok
.   Changed: Function: _ADO_Command_Execute - mlipok
.           Now return recordset
.   Changed: ADO_EXAMPLE.au3 - _Example_MSSQL_COMMAND_StoredProcedure() - mLipok
.   Removed: Function: _ADO_Connection_OpenJet - mLipok
.           Look for: _ADO_Connection_OpenConString or _ADO_ConnectionString_Excel

2016/03/08 '2.1.11 BETA'
.   New: Function: _ADO_OpenSchema_Catalogs - mLipok
.   New: Function: _ADO_OpenSchema_Tables - mLipok
.   New: Function: _ADO_OpenSchema_Columns - mLipok
.   New: Function: _ADO_OpenSchema_Indexes - mLipok
.   New: Function: _ADO_OpenSchema_Views - mLipok
.   New: Function: _ADO_Schema_GetAllCatalogs - mLipok
.   New: Function: _ADO_Schema_GetAllTables - mLipok
.   New: Function: _ADO_Schema_GetAllViews - mLipok
.   Removed: Function: _SQL_GetTableName - mLipok
.   Removed: Function: _ADO_Connection_OpenExcel - mLipok
.       Look for: _ADO_Connection_OpenConString and _ADO_ConnectionString_Excel
.   Changed: ADO_EXAMPLE.au3 - _Example_MySQL() - mLipok
.   Changed: ADO_EXAMPLE.au3 - _Example_PostgreSQL() - mLipok
.   Renamed: Function: _ADO_Command >> _ADO_Command_Create - mLipok
.   Changed: Function: _ADO_Command_Create: Parameters removed - $sQuery - mLipok
.   New: Function: _ADO_Command_CreateParameter - mlipok
.   New: Function: _ADO_Command_Execute - mlipok    .
.   Added: ADO_EXAMPLE.au3 - _Example_MSSQL_COMMAND_StoredProcedure() - mLipok

 

 

ADO 2.1.15 BETA.zip

  • Like 1



User Feedback

You may only provide a review once you have downloaded the file.


Skysnake

· Edited by Skysnake

   3 of 3 members found this review helpful 3 / 3 members

 

I have been working with this ADO.AU3 UDF for more than a year.  

At the time of writing this, I am using beta 2.1.15.  ADO in general allows connection to various data sources.  The full documentation is available from Microsoft and a simple Google search will reveal the scope.

This ADO UDF is very powerful and incorporates ideas from various other UDFs available on the Forums, such as the SQL UDF and others.  The ADO UDF provides for an ADO connection using COM objects.  The design is such that little knowledge of either ADO or COM is required.  

Combining ADO with AutoIt creates a very powerful package.  The way this UDF is implemented it is not necessary to have deep ADO knowledge in order to connect and perform tasks.

Since it uses ADO, in order to implement, the following is required

  • a data source (such as a database)
  • ODBC DNS driver and entry in the Windows Control Panel
  • this ADO UDF 
  • #include of ADO.au3 in the user script

Note that the examples should work by default.  Note the connection values in each example.

 

I have personally tested the ADO UDF on PostgreSQL databases, both locally and online, DBFs both locally and remote and briefly tested connectivity to other data sources.  It all works as expected.

I do not use the power of ADO to the full extent, as my needs are limited to basic reporting.  The advantage is that standard SQL queries can be run over ADO to the data source - even to DBF files!

 

The most important changes in this version 2.1.15 beta are as described below.  

The COM error handling makes provision for standard SQL blank result sets.  This means that COM errors such as no-connection, faulty queries etc will result in a crash.  Valid SQL with valid SQL responses can be processed in a manner which does not lead to a crash, but processed as a normal result.  At the same time, a different implementation of the same UDF (this means you write your own part of the AutoIt code differently) means that such a blank result set may represent a blank ADO cursor, which must result in an ADO / COM error.

The advantage is that a single UDF can now be implemented in different scenario's, on various data sources, with different error handling processes.  

I recommend this ADO.AU3 UDF to anyone wishing to connect to any external data source.

Skysnake

  • Like 3

Share this review


Link to review
  • Similar Content

    • Blois
      By Blois
      Hi Guys,
      Fine?
      I have this code and I use it to perform the query, however when I change the query to INSERT it is not working return error.
       
      #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Example() Func Example()     Local $dbname = FileOpenDialog("Choose Access Database", @ScriptDir, "Access files (*.accdb)", 1)     If @error then Return SetError(@error, @extended, 0)     $adoCon = ObjCreate("ADODB.Connection")     $adoCon.Open("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & $dbname & ";Uid=;Pwd=;")     $adoRs = ObjCreate("ADODB.Recordset")     GUICreate("listview items", 550, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)     Local $idListview = GUICtrlCreateListView("Codigo    |Nome         |Valor  ", 10, 10, 520, 150) ;,$LVS_SORTDESCENDING     $queryInsert = INSERT INTO TABLENAME VALUES (''aaaaa'', ''bbbbbb'', ''cccccc'')     Local $aResult     With $adoRs         .CursorType = 2         .LockType = 3         .Open($queryInsert, $adoCon)         If @error Then             ; deal with Probable SQL error             Return SetError(1)         EndIf         If Not .EOF Then $aResult = .GetRows()         .Close()     EndWith     $adoRs = 0     _ArrayDisplay($aResult, 'UBound($aResult)=' & UBound($aResult))     For $iRow_idx = 0 To UBound($aResult) - 1         GUICtrlCreateListViewItem($aResult[$iRow_idx][0], $idListview)     Next     $adoCon.Close     GUISetState()     ; Loop until the user exits.     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 ExitLoop ;~             Case $idButton ;~                 MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)             Case $idListview                 MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)         EndSwitch     WEnd EndFunc   ;==>Example ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError)     ; Do anything here.     ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _             @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _             @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _             @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _             @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _             @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _             @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _             @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _             @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _             @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc   ;==>_ErrFunc Help, Please!
       
    • TheSaint
      By TheSaint
      Only early days at this point, but I have been pondering such a program for a while.
      As good as calibre is (thank you Kovid Goyal), which is a great and wonderful ebook suite of tools and a fair database, it does have its limitations. One of which, is how it deals with multiple libraries, another is the views you get. CalibBrowser will seek to address those.
      What CalibBrowser is not going to be, is an editor for existing calibre libraries. That will be left up to calibre, which is very much needed still, and covers many aspects I will never look at. Unlike calibre, which is quite a complex program, CalibBrowser also seeks to be simple. It is mainly a viewer, at this point, but will later be able to create its own libraries. However, it does not and will not export them to calibre, especially as calibre employs a far different method and structure to what CalibBrowser will employ.
      When CalibBrowser starts, it looks for calibre executables and the main Calibre Library. Whatever isn't found, you get prompted for with a browse option.
      A calibre library, is a set of ebook folders (Author\Ebooks) and a database file, always named metadata.db, and which causes an issue when it comes to multiple libraries, but makes life a bit easier when reconstructing any corrupted libraries. However, there are better ways to deal with that, as my program will show.
      The metadata.db file is an SQL database, so I am having a learning curve right now, as I have only ever dealt with an SQL database previously, codewise, when I created my INItoSQL program some time last year, as an exercise to prove a point.
      At the moment, things are pretty basic, and not everything works 100%. Here is a screenshot, to give an idea of it, but keep in mind, I intend to expand the current GUI for other stuff I will be adding.

      Older Screenshots
      Gawd, I just noticed the '3|7' in the Book Input field (original screenshot). I was using that during troubleshooting for the multiple images scrolling and forgot to disable it ... not that it impacts anything. When it comes to maths, I struggle a bit, especially when tired. Right scrolling was easy, with a continuous loop, was easy to implement. Left scrolling was significantly harder for my poor brain ... until I realized I needed to see them as Min and Max.
      As you can see the program is usable, and all the buttons, aside from the Program Information one, work. You can even load different calibre libraries, and even reload after making changes to one with calibre. The calibre program does not need to be running, even to view an ebook in the Calibre Reader. The combo selector for a library and the ADD button are only temporarily placed where they are, until I expand the GUI.
      My intention at this point, is to add another five thumbnail images, directly below existing. Currently they aren't clickable, but I may add that.
      Here is another screenshot, of what you see when you click the larger Cover image.

      If you want to have a play with the program as is, then you will need to also get the 'sqlite3.dll' file from some online source. When CalibBrowser starts successfully with the selected calibre library, it copies its metadata.db file to a sub-folder of the program called 'Backups'. It also creates a sub-folder in that, based on the library name, to house it. That copied file, is the one the program uses, though it does not even edit that, and file modification is checked every time the program starts with a particular library, or when you Reload or select a library. If the original source file has been modified, then the program copy is overwritten. The Reload Database button does nothing, if there is no change detected, and reports such.
      Place the required 'sqlite3.dll' file in the CalibBrowser root folder. Download includes source files (sqlite3.dll excepted).
      Also required of course, is an install of calibre, plus some ebooks in a created library - Calibre Library is the default when you first add ebooks to calibre. The Mobile Read Forums, is a great source for all things ebook, and calibre can be found there in the E-Book Software section.
      CalibBrowser.zip  - Upload 4  (previous downloads: 1 + 12 + 5)
      My apologies for the program being created in AutoIt v3.3.0.0. It is the first one I have done in a while, with an older AutoIt version. Basically my Win 7 Netbook, which has a current version of AutoIt, was busy and is always busy doing something, and not suitable for doing big projects for several reasons. My older but more powerful Win XP Laptop, has a better programming environment, better computer chair (most important for my knees etc), better external monitor (wider and newish), full size external keyboard & mouse, and a great suite of setup tools to assist me. I run several older versions of AutoIt already on my Laptop, but haven't yet determined what I need to adjust to add a current version of AutoIt to the mix. This also applies to my hugely beneficial Toolbar For Any program (one of those tools), which I constantly use with SciTE. At some point, when finished, I may update the program to the current AutoIt version ... especially as I believe I am now proficient enough to do so, having become quite familiar with it in the last year or so, making many programs with it.
      Enjoy!
       
    • 9252Survive
      By 9252Survive
      Hello guys! 

      I am having some difficulty in achieving a very simple task here. I have gone through the forums and tried some examples and UDFs but I can't seem to work it out. I would really appreciate if someone could help me out. 

      Problem:

      Currently, I am logging the required feedback from the script into a log file in a simple way ... get the info in the var >> write it in the file 

      But now I am in need to perform some analysis and need some of the values to go into an MSSQL table  in the attached format
      Also, I need to be able to use Integrated Security" or "Trusted_Connection set as true or use the logged in windows credentials to connect to the server/database




      any help will be much appreciated!!!  

      Thanks! 
    • dangr82
      By dangr82
       
      I have created this function for a database, but I can not make it work. I always have two error messages: "not an error" ... and the file created, in the script directory, does not contain anything.
      Global $sDBName = "Hen.db" Func DatabaseTable() Local $sConnDB _SQLite_Startup() If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!") Exit -1 EndIf $sConnDB = _SQLite_Open($sDBName) If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!") Exit -1 EndIf If Not _SQLite_Exec($sDBName, 'CREATE TABLE Animal ("Name", "Age");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) If Not _SQLite_Exec($sDBName, 'INSERT INTO Animale VALUES ("Charlie","5");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) _SQLite_Close($sConnDB) _SQLite_Shutdown() EndFunc  
    • argumentum
      By argumentum
      ..let's say I store in a mysql column "[1,2,11,12,123]".
      How can I make s query to get all those rows that is 1, or is 12, etc ?
      I'm using  mysqlnd 5.0.11-dev - 20120503 
      Any advise on what technique I should use is welcomed
      Thanks
      PS: ..I'm adding a comma to each end, as in  [,1,2,11,12,123,] and will search with like %,12,% .
      Not pretty but I'm in a hurry and can't come up with a better solution =/
×