badboii
(Fresh Scripter)
2002-08-20 11:57 PM
MS Access Database vs. Kix 4.10

Hello all,

The following code works with 4.02 but DOESN'T work with 4.10. 4.10 is deployed and currently being used on our network. To get this inventory system to work I have to call a separate batch file to use the 4.02 version of wkix32.exe. This makes the logon sequence much longer and noticable. Can you gurus look at the code and tell me what I'm doing wrong? [Confused] [Confused] [Confused]

code:
;***** Begin Inventory
;Retrieve info by calls to WMIQuery() function

$uptime= WMIQuery("LastBootUpTime","Win32_OperatingSystem")
$wmientry=''+SubStr($uptime,5,2)+'-'+SubStr($uptime,7,2)+'-'+Left($uptime,4)+' '+SubStr($uptime,9,2)+':'+SubStr($uptime,11,2)+':'+SubStr($uptime,13,2)
? @SERROR

$SystemManufacturer = WMIQuery("Manufacturer","Win32_ComputerSystem")
? @SERROR

$SystemModel = WMIQuery("Model","Win32_ComputerSystem")
? @SERROR

$SerialNo = "$TagID"
? @SERROR

$VideoCard = WMIQuery("Description","Win32_VideoController")
? @SERROR

$VideoRes = WMIQuery("VideoModeDescription","Win32_VideoController")
? @SERROR

$PhysicalMemory = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
? @SERROR

$ProcessorSpeed = WMIQuery("CurrentClockSpeed","Win32_Processor") + " Mhz"
? @SERROR

$PagefileSpace = Val(WMIQuery("TotalPageFileSpace","Win32_LogicalMemoryConfiguration"))/1024
? @SERROR

;Enumerate all disk info into arrays, then cross-reference for required info
$arrDeviceIDs = Split(WMIQuery("DeviceID","Win32_LogicalDisk"),"|",-1)
$arrFreeSpaces = Split(WMIQuery("FreeSpace","Win32_LogicalDisk"),"|",-1)
$arrTotalSizes = Split(WMIQuery("Size","Win32_LogicalDisk"),"|",-1)
$arrFormats = Split(WMIQuery("FileSystem","Win32_LogicalDisk"),"|",-1)
For $Counter = 0 To Ubound($arrDeviceIDs)
If $arrDeviceIDs[$Counter] = "C:"
$C_DriveFormat = $arrFormats[$Counter]
$C_DriveFreeSpace = $arrFreeSpaces[$Counter]
$C_DriveTotalSize = $arrTotalSizes[$Counter]
$Counter = Ubound($arrDeviceIDs) + 1
EndIf
Next

; -- Switch the order of the Full Names
$NumCharsInFullName = Len(@FULLNAME)
$LocationOfWhiteSp = InStr(@FULLNAME," ")
$lastN = SubStr(@FULLNAME,1,($LocationOfWhiteSp - 1))
$firstN = SubStr(@FULLNAME,$LocationOfWhiteSp,($NumCharsInFullName - $LocationOfWhiteSp) + 1)
$fullName = Ltrim($firstN) + Chr(32) + Rtrim($lastN)

$CHECK_ENTRY_USERS = "SELECT * FROM TBL_USERS WHERE USERNAME='@USERID';"

$DATABASE = "\\it-fserver\temp\inventory97.mdb"
? @SERROR

$DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=$DATABASE"
? @SERROR

$objConn = DBConnOpen($DSN,15,15)
? @SERROR

$recordset = DBRecordsetOpen($objConn,'$CHECK_ENTRY_USERS',,'3','3')
? @SERROR

;Create new record if none exists to update
If $recordset.RecordCount < 1
$recordset.AddNew
? @SERROR
EndIf

; CODE DIES RIGHT HERE!!!!!
; ERR: Object referencing a closed or invalid connection.) [-2147352567/80020009]UserName
; Script error: unknown OR unexpected command [.Value]! $recordset.Fields("UserName").Value = @USERID
$recordset.Fields("UserName").Value = @USERID
? @SERROR
$recordset.Fields("FullName").Value = $fullName
? @SERROR
$recordset.Fields("Workstation").Value = @WKSTA
? @SERROR
$recordset.Fields("PrivilegeLevel").Value = @PRIV
? @SERROR
$recordset.Fields("LastUpdate").Value = @DATE + " " + @TIME
? @SERROR

;Update the new record and close the recordset object
$recordset.Update

$RC = DBRecordsetClose($recordset)

$RC = DBConnClose($objConn)



Sealeopard
(KiX Master)
2002-08-21 04:07 PM
Re: MS Access Database vs. Kix 4.10

Yes, it's a known problem with KiXtart 4.10+ and right now the DB... UDFs are only compatible with KiXtart 4.02. I'm working on fixing them to make them compatible with all 4.x versiosn.

badboii
(Fresh Scripter)
2002-08-22 12:25 AM
Re: MS Access Database vs. Kix 4.10

Thanks I needed to know that.