Habe das jetzt mal in meine Access UDF übertragen.
Danke nochmal an Moombas für den Input ![]()
_Get_Records with Column Names
AutoIt
#Region _Get_Records with Column Names
; #FUNCTION# ====================================================================================================================
; Name ..........: _Get_Records
; Description ...: This function will collect data from an access database and give it as an array.
; Syntax ........: _Get_Records($sSQLstring)
; Parameters ....: $sSQLstring - SQL Statement for creating table.
; Return values .: If success, then it will return the data as an array. If any errors see this list
; Return -1 - Connection error
; Return -2 - Recordset error
; Return -3 - No data in that table
; Author ........: kcvinu
; Modified ......: sep 2015
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: _Get_Records("SELECT [Column1],[Column2] FROM MyTable WHERE Column3 = '2500' ;") ; See the single quote.
; ===============================================================================================================================
Func _Get_Records($sSQLstring)
If Not IsObj($objConnection) Then Return -1
If Not IsObj($objRecordSet) Then Return -2
_Open_Recordset($sSQLstring)
If Not $objRecordSet.RecordCount Or ($objRecordSet.EOF = True) Then Return -3
Dim $arrRecords, $column_name
If Not @error Then
;Local $header[$objRecordSet.Fields.Count], $rows
For $i = 0 To $objRecordSet.Fields.Count - 1
$column_name &= $objRecordSet.Fields($i).Name & "|"
Next
;MsgBox(0,"", $column_name)
$column_name = StringTrimRight($column_name, 1)
$arrRecords = $objRecordSet.GetRows()
_ArrayInsert($arrRecords, 0, $column_name)
EndIf
_Close_RecordSet()
Return $arrRecords
EndFunc
#EndRegion
Alles anzeigen