break on
$ = setoption('wrapateol','on')
$cnstring = "DRIVER={SQL Server};SERVER=wheeler-sqlsrv;UID=Inventory;PWD=kixscript;DATABASE=inventory"
$cmdtxt = "select * from _tbl_Main where Wksta = '@WKSTA'"
$cn=CreateObject("ADODB.Connection")
$cmd=CreateObject("ADODB.Command")
$rs=CreateObject("ADODB.RecordSet")
? 'Error = '+@ERROR+' - '+@SERROR
$cn.connectionstring = $cnstring
$cn.open
? 'Error = '+@ERROR+' - '+@SERROR
$cmd.activeconnection = $cn
$rs.cursortype = 3
$rs.locktype = 3
$rs.activecommand = $cmd
? 'Error = '+@ERROR+' - '+@SERROR
$cmd.commandtext = $cmdtxt $rs.open ($cmd)
? 'Error = '+@ERROR+' - '+@SERROR
;*** ADD RECORDS TO THE DATABASE ***
IF $rs.eof = -1 ; addnew is only needed if a record for this workstation was not found.
$rs.addnew
ENDIF
$rs.fields.item("wksta").value = '"'+@wksta+'"'
$rs.fields.item("Model").value = "PC Model"
$rs.fields.item("IPAddr").value = '"'+@ipaddress0+'"'
$rs.fields.item("UserID").value = '"'+@userid+'"'
$rs.update
? 'Error = '+@ERROR+' - '+@SERROR
$rs.close