PDA

View Full Version : VBScript output to a database (WXP-Pro)



LeeSteventon
03-19-2004, 05:28 AM
Hi all,

Sorry for the novice scripter question!

I am writing a few VBScripts (with the help of Scriptomatic from MS). The output on screen is great but how do I send this info to a databse such as Access or SQL Server?

ANY help would be appreciated !

Regards

Lee

wchull
03-30-2004, 06:34 PM
Have you thought about simply outputting the information into a tabbed delimited file and then simply using that file as input into excel or access? Not that what you want to do is impossible, its' just a bit difficult to do for a novice scripter. Tabbed delimited files are fairly easy to deal with as the tab character is predefined and always available by simply using the variable named VBTAB. You would setup you output line as:

outputline = string1 & vbtab & string2 & vbtab & string3

You then write the lines to an output file and you're done.

Belaflek
04-12-2004, 08:08 AM
ADO database object.
Const adOpenStatic = 3
Const adLockOptimistic = 3
On Error Resume Next
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = Inventory.mdb"
Dim strComputer, objComputer, objRecordSet, objWMIService



For Each strComputer In Domain
objComputer = strComputer.name
objRecordSet.Open "SELECT * FROM [General]", _
objConnection, adOpenStatic, adLockOptimistic
If objRecordSet.EOF = True Then
objRecordSet.AddNew
Else
objRecordSet.MoveFirst
objRecordSet.AddNew
End If


objRecordSet("ComputerName") = objComputer
'WScript.Echo objComputer

'Get Physical memory
Set objWMIService = GetObject("winmgmts:\\" & objComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
objRecordSet("RAM") = Int(objItem.TotalPhysicalMemory/1048576)
' WScript.Echo Int(objItem.TotalPhysicalMemory/1048576)
Next