Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parentheses when calling a sub

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hi all,

The below code seems to have stopped working when i have put it into SSIS and took it back out again. Not sure what i have done!

Code:
StrConnect = "Driver={SQL Server};Server=(local);Database=audit;UID=sa;PWD=password"
cnt = CreateObject("ADODB.Connection")
cnt.Open(StrConnect)

recordSet = CreateObject("ADODB.Recordset")
SQLStr = "Select * from aduseroutput where lastlogontimestamp <> 0 and objectclass = 'user'"
recordSet.Open(SQLStr, cnt, 1, 1)

recordset.MoveFirst()
x = 0
Do Until recordset.EOF

    objUser = GetObject("LDAP://" & recordset.fields(0).Value)
    objLastLogon = objUser.Get("lastLogonTimestamp")
    objLastLogon = objLastLogon.HighPart * (2 ^ 32) + objLastLogon.LowPart
    objLastLogon = objLastLogon / (60 * 10000000)
    objLastLogon = objLastLogon / 1440
    objLastLogon = objLastLogon + #1/1/1601#

    cnt.Execute("Update aduseroutput set Convlastlogontimestamp = '" & cstr(objLastLogon) & "' where DN = '" & Recordset.fields(0).Value & "'")

    objUser = Nothing
    objLastLogon = Nothing
    Recordset.MoveNext()
Loop


recordset.Close()
cnt.Close()
recordset = Nothing
cnt = Nothing

I am getting cannot use parentheses when calling a sub. on line 8 (recordset open). I am sure this was working before!

Any ideas?

Daniel

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
forget that - all my sets have vanished!

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
>recordSet = CreateObject("ADODB.Recordset")
[tt][red]set[/red] recordSet = CreateObject("ADODB.Recordset")[/tt]

>recordSet.Open(SQLStr, cnt, 1, 1)
[tt]recordSet.Open SQLStr, cnt, 1, 1[/tt]
or, personally less preferrably,
[tt]call recordSet.Open(SQLStr, cnt, 1, 1)[/tt]

> objUser = GetObject("LDAP://" & recordset.fields(0).Value)
[tt][red]set[/red] objUser = GetObject("LDAP://" & recordset.fields(0).Value)[/tt]

objLastLogon = objUser.Get("lastLogonTimestamp")
[tt][red]set[/red] objLastLogon = objUser.Get("lastLogonTimestamp")[/tt]

Same for these.
>objUser = Nothing
>objLastLogon = Nothing
>recordset = Nothing
>cnt = Nothing

 
Code:
StrConnect = "Driver={SQL Server};Server=(local);Database=audit;UID=sa;PWD=password"
[!]Set [/!]cnt = CreateObject("ADODB.Connection")
cnt.Open(StrConnect)

[!]Set [/!]recordSet = CreateObject("ADODB.Recordset")
SQLStr = "Select * from aduseroutput where lastlogontimestamp <> 0 and objectclass = 'user'"
recordSet.Open(SQLStr, cnt, 1, 1)

recordset.MoveFirst()
x = 0
Do Until recordset.EOF

    [!]Set [/!]objUser = GetObject("LDAP://" & recordset.fields(0).Value)
    [!]Set [/!]objLastLogon = objUser.Get("lastLogonTimestamp")
    objLastLogon = objLastLogon.HighPart * (2 ^ 32) + objLastLogon.LowPart
    objLastLogon = objLastLogon / (60 * 10000000)
    objLastLogon = objLastLogon / 1440
    objLastLogon = objLastLogon + #1/1/1601#

    cnt.Execute("Update aduseroutput set Convlastlogontimestamp = '" & cstr(objLastLogon) & "' where DN = '" & Recordset.fields(0).Value & "'")

    [!]Set [/!]objUser = Nothing
    [!]Set [/!]objLastLogon = Nothing
    Recordset.MoveNext()
Loop

recordset.Close()
cnt.Close()
[!]Set [/!]recordset = Nothing
[!]Set [/!]cnt = Nothing

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
does movefirst have parentheses?
i thought it was just objrecordset.movefirst?
 
parentheses when calling a sub
Either:
Call subName(arg1,arg2)
Or:
subName arg1,arg2

Note:
subName(arg1)
is valid but arg1 is passed by value, not by reference.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top