Question & Answer
Question
How to use the TSM ODBC driver with VB Script?
Answer
The following sample code demonstrates how the TSM ODBC driver can be used with VB Script:
---------------------------- BEGIN TESTTSM.VBS ------------------------------
'==============================================================================
' DISPLAYTABLE.VBS
'
'
' NOTICE: This script is intended as a sample only, and is provided "as is".
'
' This sample VB Script displays all fields in all records in the
' table specified by the user.
'
' Usage:
'
' cscript displaytable.vbs <tablename>
'
' where <tablename> is the name of a valid TSM table
'
' Examples:
'
' 1. Display the contents of the ADMINS table:
'
' cscript displaytable.vbs admins
'
' 2. Display the contents of the SESSIONS table:
'
' cscript displaytable.vbs sessions
'==============================================================================
dim dbc
dim recordSet
dim sql
dim recordNum
dim fieldIndex
dim myArray
dim field
call testTsm
sub testTsm
set dbc = WScript.CreateObject("ADODB.Connection")
set recordSet = WScript.CreateObject("ADODB.Recordset")
WScript.Echo "Connecting to TSM server..."
dbc.Open "mydsn", "myadmin", "xxxxx"
WScript.Echo "Connected!"
WScript.Echo
Access the table specified by the user.
sql = "select * from " & WScript.Arguments(0)
recordSet.Open sql, dbc
myArray = recordSet.GetRows()
recordNum = 0
Iterate through each record.
for r = 0 to UBound(myArray, 2)
WScript.Echo "RECORD #" & recordNum & ":"
fieldIndex = 0
Display each field in the record.
for each field in recordSet.Fields
WScript.Echo " " & field.Name & ": " & myArray(fieldIndex, r)
fieldIndex = fieldIndex + 1
next
recordNum = recordNum + 1
WScript.Echo
next
recordSet.Close()
dbc.Close()
end sub
----------------------------- END TESTTSM.VBS -------------------------------
Was this topic helpful?
Document Information
More support for:
Tivoli Storage Manager
Software version:
4.2.2, 5.1
Document number:
663779
Modified date:
17 June 2018
UID
swg21104300