Finally, the word document pops-up containing the short sentence.
Example Two: Finding the Number of Tables
in a Database
Step 2: Adding Another ActiveX Script Task
to the Project
1. Disable the ActiveX Script Task??”Count Spelling Errors by right-clicking
the component and choosing Disable.
2. Drag and drop an ActiveX Script Task on to the Canvas from the Control
Flow Items group in the Toolbox.
This brings up the ActiveX Script Task Editor window, as
described previously.
3. In the General list item, provide a Name and a Description for
the component.
For this example, the Name is "How many Tables?", and the Description is
"Finding the number of tables in a database".
Chapter 18
[ 269 ]
4. In the Script list item, click and invoke the ActiveX Script text editor
window, as shown in the previous example.
5. Type in the following script in the ActiveX Script text editor window.
The window should appear as shown in the next screenshot.
Fully commented code is given below.
Function Main ()
'The function Main is the entry point
Dim i
'The next statement creates a SQL DMO object
Set objSQLServer = CreateObject ("SQLDMO.SQLServer")
'Connecting to the SQL Server, provide Server name,
Username, Password
objSQLServer.Connect ".","sa", "xxxxxxx"
'Provide a reference to the database on this server.
Set myDB= objSQLServer.Databases ("MyNorthwind")
'Count the number of tables in this database and display it
MsgBox (myDB.Tables.
Pages:
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189