#22143 - 2002-08-09 10:12 PM
Re: SW Inventory to DB Challenge
|
Waltz
Seasoned Scripter
Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
|
I'm right, I was wrong! It's not an ODBC issue, so it (must?)/might be a kix COM syntax thingie... Still confused about why dbopenrecordset() fails, and will continue to pursue it. In the meantime, I have a workaround - just execute an sql insert into the database. It ain't purty (yet) but it works using this 'development' code... code:
; notes: - sql reserved names include date and time. ; - changed db field names date to currentdate and time to currenttime ; - sql string values should be in 'single quotes', *not* "double quotes" ; ;*********** make a db connection ************************* $db = "c:\program files\kixtart\kixdatabase\swinv.mdb"
$cn = createobject("adodb.connection")
$cn.connectionstring = "data source=$db; provider=microsoft.jet.oledb.4.0;persist security info=false"
$cn.open() ; ;*********************** get the inventory data and write it to the db *********** $array = GetUninstallInfo() $vardate=@date $vartime=@time $varwksta=@wksta For Each $varapp in $array $rs = $cn.execute("insert into inventory (computername,program,currentdate,currenttime) values ('$varwksta','$varapp','$vardate','$vartime')") ;? "insert : @error @serror"
next ; ;************************ read it back from the db **************** $rs = $cn.execute('select * from inventory')
while not $rs.eof()
? $rs.fields("currentdate") ":" $rs.fields("currenttime") "-" $rs.fields("computername") " " $rs.fields("program")
$rs.movenext
loop ;***************** clean up and go home *********************************** $cn.close() $cn = 0
exit 1 ;****************************** Function GetUninstallInfo() dim $Index, $Key, $RC, $Value, $RootKey dim $progs[0] $Index = 0
$RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$Key = EnumKey($RootKey, $Index) While @Error = 0 ReDim PRESERVE $progs[$Index] $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf Else $Value = $Key EndIf $progs[$Index] = $Value $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop $GetUninstallInfo = $progs EndFunction
bleonard... Refer to clpowell's original post that started this thread re database structure... In my incarnation The database name is swinv.mdb The table name is inventory The field names are computername,program,currentdate,currenttime and my database weapon is MS Access 97
Cheers...
_________________________
We all live in a Yellow Subroutine...
|
|
Top
|
|
|
|
#22144 - 2002-10-22 11:30 AM
Re: SW Inventory to DB Challenge
|
Paco
Lurker
Registered: 2002-10-22
Posts: 1
Loc: Brussels
|
Hi,
The 4.11 still creates the same error (-2147352567 System Error=COM exception error "Execute" (ADODB.Command - The connection cannot be used to perform this operation. It is either closed or invalid in this context.) [-2147352567/80020009] ) on a connection to an SQL server DB. I checked with 4.02 and it works. I saw that you used 4.12 Beta: where can I find this version?
Thanks
_________________________
Paco Marcelis
|
|
Top
|
|
|
|
#22147 - 2005-03-02 12:26 PM
Re: SW Inventory to DB Challenge
|
ClientMaster
Fresh Scripter
Registered: 2005-01-19
Posts: 46
Loc: Tokyo, Japan
|
_________________________
How can you know good, unless you experience bad.
|
|
Top
|
|
|
|
#22149 - 2005-03-03 03:26 AM
Re: SW Inventory to DB Challenge
|
ClientMaster
Fresh Scripter
Registered: 2005-01-19
Posts: 46
Loc: Tokyo, Japan
|
I am sorry. I had written something but it didn`t show....
I used the script to log to database. This worked wonderfully... I did notice that this writes entries everytime a workstation runs the script. Is there any way to ensure that if entries exist for a workstation, that they are only updated, not new ones created again?
_________________________
How can you know good, unless you experience bad.
|
|
Top
|
|
|
|
#22151 - 2005-03-03 04:30 AM
Re: SW Inventory to DB Challenge
|
ClientMaster
Fresh Scripter
Registered: 2005-01-19
Posts: 46
Loc: Tokyo, Japan
|
Any ideas on how to do that???
_________________________
How can you know good, unless you experience bad.
|
|
Top
|
|
|
|
#22153 - 2005-03-04 02:22 PM
Re: SW Inventory to DB Challenge
|
ClientMaster
Fresh Scripter
Registered: 2005-01-19
Posts: 46
Loc: Tokyo, Japan
|
I am still having trouble. The records are being created...
I was wondering if anyone knew how to change the SQL: Delete from Tablename where Fieldname = 'ComputerName'
Insert TableName (Field1, Field2, Field3) values (1, 'computername', 'software')
into KIX language... I also noticed that this lists all the software in the same field... Is there a way to have it create 1 record for each PC, and then add fields for varying amount of software installed?
_________________________
How can you know good, unless you experience bad.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 918 anonymous users online.
|
|
|