Sign in to follow this  
Followers 0
Ghost21

Sql Lsting issue

5 posts in this topic

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")

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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")

EndIf

So it stays inside the for loop and it still give me the The requested action with this object has failed.:

HELP!!! PLEASE :)

Share this post


Link to post
Share on other sites

$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 put in the ERROR Handler and it came up with

Error Number: 80020009

Win Description:

Script Line: 551

but that line is: $oRS.Open("Select * FROM ACTIVE2 WHERE PC = '" & $PC & "';", $oConn, 1, 3)

Driving me Crazy....

Share this post


Link to post
Share on other sites

$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

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  
Followers 0