Bandwidth Monitor
SQLDTS.comSQLIS.comSQLIS Wiki
Enumerating DTS Packages using VB.Net
By Allan Mitchell
Version 7.0/2000
Level Beginner

Here is a very quick and easy way to enumerate through our DTS Packages using VB.Net

Dim cnString As String

'Build a connection string
cnString = "Database=msdb;integrated Security=True;Server=AM2"

'Create a connection
Dim DTSConnection As New System.Data.SqlClient.SqlConnection(cnString)

'Create a command object with query and connection as arguments
Dim DTSCommand As New System.Data.SqlClient.SqlCommand("EXEC sp_enum_dtspackages", DTSConnection)

'open the command's connection object up
DTSCommand.Connection.Open()

'Read what is contained in the command
Dim DTSReader As System.Data.SqlClient.SqlDataReader = _
	DTSCommand.ExecuteReader(Data.CommandBehavior.Default)

'Whilst we still have records in there
While DTSReader.Read()
	'Do something with the record
	MsgBox(DTSReader.GetString(0))
End While


'Clear up
DTSReader.Close()
DTSConnection.Close()