Cory,

Give this script a whirl - first change it to your specific settings, etc...

It basically checks to see if a host record already exists, if not, it creates one. Then it proceeds to update the database directly through the recordset object. I still think there is room for more performance improvements here... give it a shot...


code:

break on


$db = "m:\msaccess\logon.mdb"
$dsn = "data source= $db; provider= microsoft.jet.oledb.4.0;"
$table = "logon"
$select = "SELECT * FROM LOGON WHERE COMPUTERNAME='@WKSTA'"


$adcmdtext = "1"
$adlockoptimistic = "3"
$adopenstatic = "3"
$adopendynamic = "2"
$adopenkeyset = "1"


$connection = olecreateobject("adodb.connection")
$xconnection = dectohex($connection)
$recordset = olecreateobject("adodb.recordset")


if $connection and $recordset


$= olecallfunc($connection,"open","s","$dsn")


if @error = 0


$= olecallfunc($recordset,"open","sosss","$select","$xconnection",
"$adopenkeyset","$adlockoptimistic","$adcmdtext")


if @error = 0


$fields = val("&"+olegetproperty($recordset,"fields"))
$computername = val("&"+olecallfunc($fields,"item","s","computername"))
$stamp = val("&"+olecallfunc($fields,"item","s","stamp"))
$userid = val("&"+olecallfunc($fields,"item","s","userid"))
$pctype = val("&"+olecallfunc($fields,"item","s","pctype"))
$hwtype = val("&"+olecallfunc($fields,"item","s","hwtype"))
$spver = val("&"+olecallfunc($fields,"item","s","spver"))
$adminequiv = val("&"+olecallfunc($fields,"item","s","adminequiv"))

if olegetproperty($recordset,"recordcount") = 0


$= olecallfunc($recordset,"addnew")
$= oleputproperty($computername,"value","s","@WKSTA")


endif


$admin = ingroup("\\@wksta\administrators")


$= oleputproperty($stamp,"value","s","@TIME")
$= oleputproperty($userid,"value","s","@USERID")
$= oleputproperty($pctype,"value","s","@INWIN")
$= oleputproperty($hwtype,"value","s","HP")
$= oleputproperty($spver,"value","s","@DOS")
$= oleputproperty($adminequiv,"value","s","$admin")


$= olecallfunc($recordset,"update")


$= olereleaseobject($fields)
$= olereleaseobject($computername)
$= olereleaseobject($stamp)
$= olereleaseobject($userid)
$= olereleaseobject($pctype)
$= olereleaseobject($hwtype)
$= olereleaseobject($spver)
$= olereleaseobject($adminequiv)


endif


endif


$= olecallfunc($recordset,"close")
$= olecallfunc($connection,"close")
$= olereleaseobject($recordset)
$= olereleaseobject($connection)


endif


exit


Shawn.