$acc_pwd = "wyl"
$datadir = "\\test\data$\newpcrecord.mdb"
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datadir & ";Jet Oledb:Database Password=" & $acc_pwd)
$RS.ActiveConnection = $addfld
$RS.Open("Select * From asset where assetTag='" & $AssetTag & "'")
If $RS.eof And $RS.bof Then
$insert = 'INSERT INTO asset (username,dispalyname,assetTag,sn,ip,mac,hostname,ram,disk,process,cpu,osname,nowdate,symantec,soeversion,rrssd,rrsam,rrsrc) VALUES ("' & $username & '","' & $displayname & '","' & $AssetTag & '","' & $sn & '","' & $IP & '","' & $mac & '","' & $hostname & '","' & $ram & '","' & $disk & '","' & $Process & '","' & $cpu & '","' & $osname & '","' & $nowdate & '","' & $symantec & '","' & $soeversion & '","' & $rrssd & '","' & $rrsam & '","' & $rrsrc & '")'
$addfld.Execute($insert)
$addfld.close
;MsgBox(262144,"","该机器安装信息登记成功",2)
Else
$insert = "UPDATE asset SET username = '" & $username & "', dispalyname = '" & $displayname & "', nowdate= '" & $nowdate & "', ip= '" & $IP & "' , symantec= '" & $symantec & "' ,soeversion='" & $soeversion & "', rrssd= '" & $rrssd & "', rrsam='" & $rrsam & "', rrsrc='" & $rrsrc & "' WHERE assetTag = '" & $AssetTag & "'"
$addfld.Execute($insert)
$addfld.close
;MsgBox(262144,"","该机器安装信息更新成功",2)
EndIf
根据以上的代码改下,如果有重复项则写入数据库,否则放弃写入数据库。不知这样是否可实现LZ的想法。