Ghost21 Posted December 17, 2008 Share Posted December 17, 2008 When I run this it finds the first pc in the domain and adds it no problem. When it goes back to $oRS.Open("Select PC FROM ACTIVE2 WHERE PC = '" & $PC & "'", $oConn, 1, 3) the second time around it crashes and says " The requested action with this object has failed. " I thought that meant that the database wasn't open but I can see it is. Any sussgestions ? $domain = "YOURDOMAIN" Local $ObjDomain = ObjGet("WinNT://" & $domain) Call("dbOpen") For $Object In $ObjDomain If $Object.class = "Computer" Then $PC = $Object.Name $oRS.Open("Select PC FROM ACTIVE2 WHERE PC = '" & $PC & "'", $oConn, 1, 3) $oRS.RecordCount If $oRS.RecordCount = 1 Then MsgBox(0, "TEST", "'" & $PC & "'") $SQLstring = "UPDATE ACTIVE2 SET PC = '" & $PC & " - " & "MSHOME" & "', USER = '" & $USER & "', IP = '" & $IP & "', PING = '" & $PING & "', DEPT = '" & $DEPT & "', LASTUPDATED = '" & $LASTUPDATED & "' WHERE PC = '" & $PC & "';"; IN UPDATE RECORDS YOU DON'T NEED THE TRAILING BRACKET " ) " $oConn.Execute($SQLstring) $oRS.MoveNext Else MsgBox(0, "TEST 2 NEW RECORD", "'" & $PC "'") $oConn.Execute("INSERT INTO ACTIVE2 (PC,USER,IP,PING,DEPT,LASTUPDATED) VALUES ('" & $PC & "','" & $USER & "','" & $IP & "','" & $PING & "','" & $DEPT & "','" & $LASTUPDATED & "');") EndIf Else EndIf Next Call("dbClose") Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 17, 2008 Share Posted December 17, 2008 When I run this it finds the first pc in the domain and adds it no problem. When it goes back to $oRS.Open("Select PC FROM ACTIVE2 WHERE PC = '" & $PC & "'", $oConn, 1, 3) the second time around it crashes and says " The requested action with this object has failed. " I thought that meant that the database wasn't open but I can see it is. Any sussgestions? $domain = "YOURDOMAIN" Local $ObjDomain = ObjGet("WinNT://" & $domain) Call("dbOpen") For $Object In $ObjDomain If $Object.class = "Computer" Then $PC = $Object.Name $oRS.Open("Select PC FROM ACTIVE2 WHERE PC = '" & $PC & "'", $oConn, 1, 3) $oRS.RecordCount If $oRS.RecordCount = 1 Then MsgBox(0, "TEST", "'" & $PC & "'") $SQLstring = "UPDATE ACTIVE2 SET PC = '" & $PC & " - " & "MSHOME" & "', USER = '" & $USER & "', IP = '" & $IP & "', PING = '" & $PING & "', DEPT = '" & $DEPT & "', LASTUPDATED = '" & $LASTUPDATED & "' WHERE PC = '" & $PC & "';"; IN UPDATE RECORDS YOU DON'T NEED THE TRAILING BRACKET " ) " $oConn.Execute($SQLstring) $oRS.MoveNext Else MsgBox(0, "TEST 2 NEW RECORD", "'" & $PC "'") $oConn.Execute("INSERT INTO ACTIVE2 (PC,USER,IP,PING,DEPT,LASTUPDATED) VALUES ('" & $PC & "','" & $USER & "','" & $IP & "','" & $PING & "','" & $DEPT & "','" & $LASTUPDATED & "');") EndIf Else EndIf Next Call("dbClose") Perhaps you should $oRS.Close before running the $oRS.Open(...) again. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Ghost21 Posted December 17, 2008 Author Share Posted December 17, 2008 Perhaps you should $oRS.Close before running the $oRS.Open(...) again. $oRS.Close <-- Isn't that like closing the database ? Won't that affect speed as well ?I put this in to even check If IsObj($oConn) Then $oConn.close $oConn = 0 Else Call("dbOpen") EndIfSo it stays inside the for loop and it still give me the The requested action with this object has failed.:HELP!!! PLEASE Link to comment Share on other sites More sharing options...
Ghost21 Posted December 17, 2008 Author Share Posted December 17, 2008 $oRS.Close <-- Isn't that like closing the database ? Won't that affect speed as well ?I put this in to even check If IsObj($oConn) Then $oConn.close $oConn = 0 Else Call("dbOpen") EndIfSo it stays inside the for loop and it still give me the The requested action with this object has failed.:HELP!!! PLEASE I put in the ERROR Handler and it came up withError Number: 80020009Win Description:Script Line: 551but that line is: $oRS.Open("Select * FROM ACTIVE2 WHERE PC = '" & $PC & "';", $oConn, 1, 3)Driving me Crazy.... Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 17, 2008 Share Posted December 17, 2008 $oRS.Close <-- Isn't that like closing the database ? Won't that affect speed as well ? I put this in to even check If IsObj($oConn) Then $oConn.close $oConn = 0 Else Call("dbOpen") EndIf So it stays inside the for loop and it still give me the The requested action with this object has failed.: HELP!!! PLEASE I don't have anything to test the theory on at the moment, but I didn't mean close $oConn, just $oRS: For $Object In $ObjDomain If $Object.class = "Computer" Then $PC = $Object.Name $oRS.Open("Select PC FROM ACTIVE2 WHERE PC = '" & $PC & "'", $oConn, 1, 3) $oRS.RecordCount If $oRS.RecordCount = 1 Then MsgBox(0, "TEST", "'" & $PC & "'") $SQLstring = "UPDATE ACTIVE2 SET PC = '" & $PC & " - " & "MSHOME" & "', USER = '" & $USER & "', IP = '" & $IP & "', PING = '" & $PING & "', DEPT = '" & $DEPT & "', LASTUPDATED = '" & $LASTUPDATED & "' WHERE PC = '" & $PC & "';"; IN UPDATE RECORDS YOU DON'T NEED THE TRAILING BRACKET " ) " $oConn.Execute($SQLstring) $oRS.MoveNext Else MsgBox(0, "TEST 2 NEW RECORD", "'" & $PC "'") $oConn.Execute("INSERT INTO ACTIVE2 (PC,USER,IP,PING,DEPT,LASTUPDATED) VALUES ('" & $PC & "','" & $USER & "','" & $IP & "','" & $PING & "','" & $DEPT & "','" & $LASTUPDATED & "');") EndIf $oRS.Close; <=== Added here Else EndIf Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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