Jump to content
Sign in to follow this  

Help With ADODB SMS Query Error Parsing

Recommended Posts


This is a program i made to query my sms servers, and return the computer a specified user is logged on to. only problem is that if you enter in a incorrect username, a username it has no info for, or accidentaly leave it blank then the script errors out at $objRecordSetSMSdata.movefirst I have been searching for days, looking at vbs scripts, au3 scripts, and searching the forums. I dont usuially post because i can usuialy find something or figure it out. But, i am still just unable to find a way that works for this program. Here is the script for my gui users computer finder, and any help would be appreciated.


#include <GuiConstants.au3>
#Include <GuiListView.au3>

Dim $filetxtsms, $sConnString, $objSQL, $objRecordset, $objRecordSetSMSdata, $smsResourceID, $input, $listView, $oMyError

;$user = InputBox ( 'User Name', 'Please enter the User Name you wish to find' )
;If @error Then Exit

GuiCreate("Find User", 373, 190)
GuiSetIcon(@SystemDir & "shell32.dll",170)
GUICtrlCreateLabel ("Username", 10, 15, 50, 20)
$input=GUICtrlCreateInput ("", 70, 10, 100, 20)
$listView = GuiCtrlCreateListView("User Name|Computer Name|Domain", 10, 40, 353, 140)
$fbutton2 = GUICtrlCreateButton ("copy", 240,10,50,20)
$fbutton3 = GUICtrlCreateButton ("Find", 310,10,50,20,$BS_DEFPUSHBUTTON)

Opt("GUIOnEventMode", 1)

while 1
    sleep (50)

Func list()
;connect to sms
    $sConnString = "Driver={SQL Server}; Server="put your sms server here"; Database=SMS_TMP; Trusted_Connection=yes;"
    $objSQL = ObjCreate("ADODB.Connection")
    $objSQL.open ($sConnString)
;request sms info
    $objRecordSetSMSdata = ObjCreate("ADODB.RecordSet")
    $objRecordsetSMSdata.Open ("SELECT SYS.User_Name0, SYS.Netbios_Name0, SYS.User_Domain0, Operating_System_Name_and0, SYS.Resource_Domain_OR_Workgr0 FROM v_R_System SYS WHERE User_Name0 LIKE '" & $user & "' ORDER BY SYS.User_Name0, SYS.Netbios_Name0", $objSQL, 3 , 3)
;if @error then MsgBox(1,"test", "there was an error")
;$oMyError = ObjEvent ($objRecordSetSMSdata.ActiveConnection.Errors, "error")
    $objRecordSetSMSdata.movefirst;If @error then MsgBox(1,"test", "there was an error")
;if @error then MsgBox(1,"test", "there was an error")

;get sms info
while not $objRecordSetSMSdata.eof
    $smsresourceID = $objRecordSetSMSdata.Fields("User_Name0").value
    $smsresourceID2 = $objRecordSetSMSdata.Fields("Netbios_Name0").value
    $smsresourceID3 = $objRecordSetSMSdata.Fields("Resource_Domain_OR_Workgr0").value
;if MsgBox(1,"test",$smsresourceID&"    "&$smsresourceID2) = 2 Then close()
    guiCtrlCreateListViewItem($smsresourceID&"|"&$smsresourceID2&"|"&$smsresourceID3 , $listView)   
    guiCtrlCreateListViewItem(" " , $listView)

Func copy()
    if $line = "" then Return
    $line = StringSplit($line, "|")
    ClipPut ($line[2])

Func close()

;func error()
;     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 & hex($oMyError.number,8)  & @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 _
;           )
;   Local $err = $oMyError.number
;   If $err = 0 Then $err = -1
;   SetError($err); to check for after this function returns

;   $objSQL.close
;   Return

As you can see i tried a fiew methods, but lined them all out 1 to show that i was trying, and 2 because they were unsucesfull. I tried more ways, but these were the ones left in the code.

Edited by Brad

Share this post

Link to post
Share on other sites

Not sure if it'd help but you can try the MySQL.au3 in my sig. Might make it easier.


Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post

Link to post
Share on other sites

Realy don't feel like rewriting the whole code, for a single error parse, but if that is the only option i will try it, and thanks for your suggestion.

See if anyone else can think of anything.

Not sure if it'd help but you can try the MySQL.au3 in my sig. Might make it easier.


Share this post

Link to post
Share on other sites

HAHAH, i knew i shouldn't of posted, it finally came to me

i put

if $objRecordSetSMSdata.EOF Then 
        MsgBox(1,"Error", "That was an invalid username, or there is no sms info for that user")



done, and thanks for your suggestion again. hope this helps others

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this