home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Run_a_SQL_400771272001.psc / Apps / DTSRemoteControl / DTSPackages.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  2001-12-06  |  10.4 KB  |  319 lines

  1. VERSION 5.00
  2. Object = "{8D650141-6025-11D1-BC40-0000C042AEC0}#3.0#0"; "ssdw3b32.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form DTSPackages 
  5.    Caption         =   "DTS Packages Test"
  6.    ClientHeight    =   4350
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   7260
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4350
  12.    ScaleWidth      =   7260
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin MSComctlLib.StatusBar sb 
  15.       Align           =   2  'Align Bottom
  16.       Height          =   345
  17.       Left            =   0
  18.       TabIndex        =   16
  19.       Top             =   4005
  20.       Width           =   7260
  21.       _ExtentX        =   12806
  22.       _ExtentY        =   609
  23.       _Version        =   393216
  24.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  25.          NumPanels       =   1
  26.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  27.             AutoSize        =   1
  28.             Object.Width           =   12383
  29.          EndProperty
  30.       EndProperty
  31.    End
  32.    Begin VB.Frame frmDSN 
  33.       Caption         =   "DSN or DSN Less?"
  34.       Height          =   690
  35.       Left            =   4620
  36.       TabIndex        =   11
  37.       Top             =   735
  38.       Width           =   2475
  39.       Begin VB.OptionButton DSNLess 
  40.          Height          =   270
  41.          Left            =   1200
  42.          TabIndex        =   13
  43.          Top             =   285
  44.          Width           =   285
  45.       End
  46.       Begin VB.OptionButton DSN 
  47.          Height          =   270
  48.          Left            =   150
  49.          TabIndex        =   12
  50.          Top             =   285
  51.          Width           =   285
  52.       End
  53.       Begin VB.Label Label2 
  54.          AutoSize        =   -1  'True
  55.          Caption         =   "DSN-Less"
  56.          Height          =   195
  57.          Left            =   1485
  58.          TabIndex        =   15
  59.          Top             =   315
  60.          Width           =   720
  61.       End
  62.       Begin VB.Label lblDSN 
  63.          AutoSize        =   -1  'True
  64.          Caption         =   "DSN"
  65.          Height          =   195
  66.          Left            =   435
  67.          TabIndex        =   14
  68.          Top             =   315
  69.          Width           =   345
  70.       End
  71.    End
  72.    Begin VB.TextBox txtPwd 
  73.       Enabled         =   0   'False
  74.       Height          =   330
  75.       IMEMode         =   3  'DISABLE
  76.       Left            =   4770
  77.       PasswordChar    =   "*"
  78.       TabIndex        =   8
  79.       ToolTipText     =   "Password for Login to Server"
  80.       Top             =   3495
  81.       Width           =   1950
  82.    End
  83.    Begin VB.TextBox txtLogin 
  84.       Enabled         =   0   'False
  85.       Height          =   330
  86.       Left            =   4770
  87.       TabIndex        =   7
  88.       ToolTipText     =   "Login ID for Server"
  89.       Top             =   2925
  90.       Width           =   1950
  91.    End
  92.    Begin VB.TextBox txtServerName 
  93.       Enabled         =   0   'False
  94.       Height          =   330
  95.       Left            =   4770
  96.       TabIndex        =   5
  97.       ToolTipText     =   "Server Name to Login To"
  98.       Top             =   2370
  99.       Width           =   1950
  100.    End
  101.    Begin VB.TextBox txtDSNName 
  102.       Enabled         =   0   'False
  103.       Height          =   330
  104.       Left            =   4770
  105.       TabIndex        =   3
  106.       Top             =   1710
  107.       Width           =   1950
  108.    End
  109.    Begin VB.CommandButton cmdRunDTSPkg 
  110.       Caption         =   "Run DTS Pkg"
  111.       Enabled         =   0   'False
  112.       Height          =   420
  113.       Left            =   5895
  114.       TabIndex        =   2
  115.       Top             =   240
  116.       Width           =   1290
  117.    End
  118.    Begin VB.CommandButton cmdGetDTSList 
  119.       Caption         =   "List DTS Pkgs"
  120.       Height          =   420
  121.       Left            =   4575
  122.       TabIndex        =   1
  123.       Top             =   240
  124.       Width           =   1290
  125.    End
  126.    Begin SSDataWidgets_B.SSDBGrid ssdbDTSPkgs 
  127.       Height          =   3735
  128.       Left            =   105
  129.       TabIndex        =   0
  130.       Top             =   240
  131.       Width           =   4425
  132.       _Version        =   196617
  133.       DataMode        =   2
  134.       RecordSelectors =   0   'False
  135.       AllowAddNew     =   -1  'True
  136.       AllowUpdate     =   0   'False
  137.       MultiLine       =   0   'False
  138.       RowSelectionStyle=   1
  139.       AllowRowSizing  =   0   'False
  140.       AllowGroupSizing=   0   'False
  141.       AllowGroupMoving=   0   'False
  142.       AllowColumnMoving=   0
  143.       AllowGroupSwapping=   0   'False
  144.       AllowColumnSwapping=   0
  145.       AllowGroupShrinking=   0   'False
  146.       AllowColumnShrinking=   0   'False
  147.       AllowDragDrop   =   0   'False
  148.       SelectTypeRow   =   1
  149.       SelectByCell    =   -1  'True
  150.       ForeColorEven   =   0
  151.       BackColorOdd    =   16777215
  152.       RowHeight       =   423
  153.       Columns(0).Width=   7514
  154.       Columns(0).Caption=   "DTS Package to Run"
  155.       Columns(0).Name =   "DTSPkgRun"
  156.       Columns(0).DataField=   "Column 0"
  157.       Columns(0).DataType=   8
  158.       Columns(0).FieldLen=   256
  159.       Columns(0).HasForeColor=   -1  'True
  160.       Columns(0).HasBackColor=   -1  'True
  161.       Columns(0).BackColor=   16777215
  162.       _ExtentX        =   7805
  163.       _ExtentY        =   6588
  164.       _StockProps     =   79
  165.       Caption         =   "DTS Packages Available for Execution"
  166.       BeginProperty PageFooterFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  167.          Name            =   "MS Sans Serif"
  168.          Size            =   8.25
  169.          Charset         =   0
  170.          Weight          =   400
  171.          Underline       =   0   'False
  172.          Italic          =   0   'False
  173.          Strikethrough   =   0   'False
  174.       EndProperty
  175.       BeginProperty PageHeaderFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  176.          Name            =   "MS Sans Serif"
  177.          Size            =   8.25
  178.          Charset         =   0
  179.          Weight          =   400
  180.          Underline       =   0   'False
  181.          Italic          =   0   'False
  182.          Strikethrough   =   0   'False
  183.       EndProperty
  184.    End
  185.    Begin VB.Label lblPassword 
  186.       AutoSize        =   -1  'True
  187.       Caption         =   "Password:"
  188.       Enabled         =   0   'False
  189.       Height          =   195
  190.       Left            =   4755
  191.       TabIndex        =   10
  192.       Top             =   3270
  193.       Width           =   735
  194.    End
  195.    Begin VB.Label lblID 
  196.       AutoSize        =   -1  'True
  197.       Caption         =   "Login ID:"
  198.       Enabled         =   0   'False
  199.       Height          =   195
  200.       Left            =   4770
  201.       TabIndex        =   9
  202.       Top             =   2715
  203.       Width           =   645
  204.    End
  205.    Begin VB.Line Line2 
  206.       BorderWidth     =   2
  207.       DrawMode        =   1  'Blackness
  208.       X1              =   4650
  209.       X2              =   6855
  210.       Y1              =   2130
  211.       Y2              =   2130
  212.    End
  213.    Begin VB.Label lblDTSSvrNAme 
  214.       AutoSize        =   -1  'True
  215.       Caption         =   "DTS Server Name:"
  216.       Enabled         =   0   'False
  217.       Height          =   195
  218.       Left            =   4770
  219.       TabIndex        =   6
  220.       Top             =   2175
  221.       Width           =   1350
  222.    End
  223.    Begin VB.Label lblDSNNameMSDB 
  224.       AutoSize        =   -1  'True
  225.       Caption         =   "DSN Name to msdb database:"
  226.       Enabled         =   0   'False
  227.       Height          =   195
  228.       Left            =   4770
  229.       TabIndex        =   4
  230.       Top             =   1485
  231.       Width           =   2160
  232.    End
  233. Attribute VB_Name = "DTSPackages"
  234. Attribute VB_GlobalNameSpace = False
  235. Attribute VB_Creatable = False
  236. Attribute VB_PredeclaredId = True
  237. Attribute VB_Exposed = False
  238. Private Sub cmdGetDTSList_Click()
  239.     Dim cnn As ADODB.Connection
  240.     Dim rst As ADODB.Recordset
  241.     Dim sSQL As String
  242.     On Error GoTo Err_Trap
  243.     sSQL = "SELECT DISTINCT name FROM sysdtspackages"
  244.     Set cnn = New ADODB.Connection
  245.     Set rst = New ADODB.Recordset
  246.     sb.SimpleText = "Running......."
  247.     If DSN.Value = True Then
  248.         With cnn
  249.             .ConnectionString = "DATA SOURCE=" & txtDSNName.Text
  250.             .CursorLocation = adUseClient
  251.             .Open
  252.             'process the stored procedure command with no records to return
  253.             Set rst = .Execute(sSQL)
  254.         End With
  255.     Else
  256.         With cnn
  257.             .ConnectionString = "driver={SQL Server};server=" & txtServerName.Text & ";uid=" & txtLogin.Text & ";pwd=" & txtPwd.Text & ";database=msdb"
  258.             .ConnectionTimeout = 30
  259.             .Open
  260.             Set rst = .Execute(sSQL)
  261.         End With
  262.     End If
  263.     ssdbDTSPkgs.RemoveAll
  264.     While Not rst.EOF
  265.         With ssdbDTSPkgs
  266.             .AddNew
  267.             .Columns(0).Text = rst("name").Value
  268.             .Update
  269.         End With
  270.         rst.MoveNext
  271.     Wend
  272.     frmDSN.Enabled = False
  273.     cmdRunDTSPkg.Enabled = True
  274.     Call DSNLess_Click
  275.     Set rst = Nothing
  276.     Set cnn = Nothing
  277.     sb.SimpleText = "Finished!"
  278. Exit_Sub:
  279.     Exit Sub
  280. Err_Trap:
  281.     MsgBox "You possibly entered a Server or DSN name that doesn't exist" & vbCrLf & vbCrLf _
  282.     & "Check your values and try again!", vbCritical, "Problem with entries"
  283. End Sub
  284. Private Sub cmdRunDTSPkg_Click()
  285.     Dim oPKG As New DTS.Package
  286.     sb.SimpleText = "Running......."
  287.     oPKG.LoadFromSQLServer txtServerName.Text, txtLogin.Text, txtPwd.Text, 256, , , , ssdbDTSPkgs.Columns(0).Text
  288.     ' Set ExecuteInMainThread for ALL Steps
  289.     Dim i As Integer
  290.     For i = 1 To oPKG.Steps.Count
  291.         oPKG.Steps(i).ExecuteInMainThread = True
  292.     Next i
  293.     oPKG.Execute
  294.     sb.Font.Bold = True
  295.     sb.SimpleText = "Finished!"
  296.     oPKG.UnInitialize
  297.     Set oPKG = Nothing
  298. End Sub
  299. Private Sub DSN_Click()
  300.     lblDSNNameMSDB.Enabled = True
  301.     txtDSNName.Enabled = True
  302.     lblDTSSvrNAme.Enabled = False
  303.     lblID.Enabled = False
  304.     txtServerName.Enabled = False
  305.     txtLogin.Enabled = False
  306.     txtPwd.Enabled = False
  307.     lblPassword.Enabled = False
  308. End Sub
  309. Private Sub DSNLess_Click()
  310.     lblDSNNameMSDB.Enabled = False
  311.     txtDSNName.Enabled = False
  312.     lblDTSSvrNAme.Enabled = True
  313.     lblID.Enabled = True
  314.     lblPassword.Enabled = True
  315.     txtServerName.Enabled = True
  316.     txtLogin.Enabled = True
  317.     txtPwd.Enabled = True
  318. End Sub
  319.