Efo74 Posted February 22, 2011 Share Posted February 22, 2011 ;***************************************************************************************************************** Func _accessMaxID($adSource, $adTable) ;***************************************************************************************************************** $max_val_id = 0 $oADO = 'ADODB.Connection' If IsObj($oADO) Then $oADO = ObjGet('',$oADO) Else $oADO = _dbOpen($adSource) EndIf If IsObj($oADO) = 0 Then Return SetError(1) If Not IsObj($oADO) Then Return SetError(2, 0, 0) $oRec = _dbOpenRecordset() If IsObj($oRec) = 0 Then Return SetError(2) $oRec.Open ("SELECT MAX(ID) FROM " & $adTable , $oADO, $adOpenStatic, $adLockOptimistic) $max_val_id = $oRec.Fields(0).Value $oADO.Close() return $max_val_id EndFunc :rolleyes: Link to comment Share on other sites More sharing options...
spudw2k Posted February 24, 2011 Share Posted February 24, 2011 I think it would be more efficient to have a "query" function and simply supply the "select max(id)" to it rather than dedicate an entire function for that. Just my two cents. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now