View Single Post
  #2 (permalink)  
Old November 26th, 2004, 11:08 AM
mmcdonal mmcdonal is offline
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   I report the same sort of data to a SQL server instead of individual text files just because pulling them in manually is so time consuming.

   Can you make the script dump the data directly into your access database?

   Here is the pertinent part of the script I use for the SQL Server dump:

'================================================= ==
strUserName = "username"
strPassword = "password"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

'open connection using system dsn, create recordset from tblComputer
objConnection.Open "DSN=AssetManagement;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM tblComputer" , objConnection, adOpenStatic, adLockOptimistic

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

'retrieves basic system info
For Each objItem In colItems
    objRecordset.AddNew 'starts to add record to tblComputer
        objRecordset("ComputerName") = objItem.Caption
    objRecordset("Container") = objItem.Domain
        objRecordset("Manufacturer") = objItem.Manufacturer
        objRecordset("Model") = objItem.Model
        '.....................
        objRecordset.Update 'finally updates record in tblComputer
Next

objRecordset.Close
objConnection.Close
'================================================= =

You could also dump the data into an Excel spreadsheet, and then link the spreadsheet as a table to your database. Putting the data into the spreadsheet is only slightly more complicated than creating individual text files. You need to have the spreadsheet on a drive that every computer can see.

In any event, whatever script you write to pull the data from the text files to Access can just as easily be adapted to push the data directly from your script into Access (skip the text files.)

I hope this helps.



mmcdonal
Reply With Quote