Let??™s change that.
1. Select the Class1.vb file from the NWindDataAccess project in the Solution Explorer.
2. In the Properties pane (below the Solution Explorer, as shown in Figure 9-14), change
the File Name property to NWindData.vb.
Figure 9-14. Changing the class name
CHAPTER 9 n ACTIVEX AND .NET 331
Once that??™s done, all references to Class1 will be changed to reflect the new class, as
shown in Figure 9-15.
Figure 9-15. Renamed class and file name
Now we??™ll add some code to our class. This will be a very simple class that does nothing
more than query the Northwind 2007 database for a list of employees.
1. On your local PC, create a folder called C:\ExampleDBs (if you did not already do so for
the ActiveX example).
2. Copy the Northwind 2007.accdb file into the new folder.
nNote These two steps are more of a necessity for those who do not have Visual Studio 2005 (so the code
will run from the sample files you downloaded from www.apress.com). If you are using Visual Studio 2005,
you can modify the code to refer to the Northwind 2007 database from any location on your PC.
3. Put your cursor in the class module code window and press Ctrl+Home to position the
insertion point at the very beginning of the code.
4. Press Enter.
CHAPTER 9 n ACTIVEX AND .NET 332
5. Add the following statement to reference the OLEDB library:
Imports System.Data.OleDb
6. Move the insertion point to the blank line inside the class code.
7. Add the following module-level declarations:
Const TABLE_NAME As String = "Table1"
Private m_sNwindName As String
The constant TABLE_NAME will hold the table name we??™ll use when we fill a DataSet from
the Northwind Employees table.
Pages:
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305