Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
Several readers a week write, me asking questions about previous articles or questions related to current projects that they are working on. Often, it reminds me that there are developers working at all levels across this great big blue marble. One question recently was where is the data form wizard in VB.NET?
If you don't know, the Data Form Wizard is a tool in VB6 that permits you to pick a table, and it generates a data-aware form and incorporates that form into your project. In this article, we will review the Data Form Wizard in VB6 and look at how this feature was revised in VB.NET. Yes, a wizard analogous to VB6's Data Form Wizard exists in VB.NET. One just needs to know where to look.
Data Form Wizard in VB6
Figure 1: The Data Form Wizard applet.
To generate the VB6 Data Form for our example, follow the number steps below, completing the wizard in the process.
- On the Data Form Wizard Introduction page, click Next.
- For the Database Type step, pick Access as the database type.
- For the Database step, use the Browse button and browse to a sample Access database. (You can use the Nwind.mdb database for this step.) Click Next.
- Next, describe the style of form that the wizard should create. For our example, pick the Single Record Form Layout and click Next.
- For the Record Source step, pick the Customers table as the record source and move all fields from the Available Fields to the Selected Fields list.
- Click Finish.
After you have clicked Finish, a form named frmCustomers will be added to your project. The form should look similar to the form shown in Figure 2 and is a complete data-aware form, right down to the code.
Figure 2: The completed, running data-aware form created by the VB6 Data Form Wizard.
You can explore the generated code if you have a copy of VB6. This is a reasonably good way to begin learning about the kinds of code and controls you can use to manually create data-aware forms.
Data Form Wizard in .NET
The generated code and controls for a VB.NET Data Form are different, but the steps for creating a data-aware form in VB.NET are similar to those for VB6. The first thing we will need to do is create Windows Application project. Once we have created a basic project, we need to invoke and complete the wizard steps. For variety, the following steps use the Northwind (nwind.mdb) database and the VB.NET Data Form Wizard to create a master/detail form.
- Select Project|Add Windows Form from the main menu.
- Click the Data Form Wizard applet from the list of Templates (see Figure 3).
- Click Open. (This step invokes the VB.NET Data Form Wizard.)
- Click Next on the welcome step.
- For the second step, provide a name for the DataSet. (We'll use OrderDetails for our DataSet's name.)
- Click Next.
- For the next step, click the New Connection button. The New Connection button invokes the Data Link Properties dialog, which is part of OLEDB32.DLL. (This application also can be invoked by double-clicking a .udl file.)
- Select the Provider tab and pick the Microsoft Jet 4.0 OLE DB Provider (as shown in Figure 4).
- On the Connection tab, click the button associated with the "Select or enter a database name" input control. Navigate to or enter the name of your copy of the Northwind sample database. (On my laptop, this path is C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB; you can use Windows Explorer to find a copy on your PC.)
- Click Test Connection on the Connection tab. If you get a message box indicating that the test connection succeeded, click OK.
- We are now back in the Data Form Wizard; click Next.
- In the Available items list, select the Orders and Order Details tables, moving them to the Selected items list. Click Next.
- The next step is to specify the relationship between Order and Order Details. The parent table is Orders and the child table is Order Details. The index column that expresses this relationship is OrderID (see Figure 5). Click Next.
- For the final step, select Orders as the master table and Order Details as the detail table.
- Click Finish.
Figure 3: Select Data Form Wizard from the list of Templates in the Add New Item dialog.
Figure 4: The Data Link Properties application is part of OLEDB32.DLL.
Figure 5: Describe the relationship between Order and Order Details as shown in the figure.
After the last step, a dialog will pop up, asking whether you want to include a password or not. I didn't use a password; you can if you want to.
Visual Basic .NET's wizard does some extra, interesting things. In addition to generating a data-aware form that is ready to run, Visual Basic .NET uses the XSD.EXE tool to generate an XML schema and from that a strongly-typed DataSet. The XML Schema designer permits you to visually manage the tables and relationships, and the strongly-typed DataSet will permit you to write code that is more expressive if you elect to customize the generated form.
For more information on the XML Schema designer, DataSets, DataRelations (used to express our master/detail relationship), and strongly-typed DataSets, check out the integrated help in VS.NET or, better yet, pick up a copy of my book Visual Basic .NET Power Coding from Addison Wesley.
Occasionally, I talk to developers who worry that what was great about VB6 is gone in VB.NET. In fact, the opposite is true. Many of the great features that made it easy to develop with VB6 still exist in .NET and many more cool features have been added. My favorite part of VB.NET is the framework itself. With VB.NET, I can build applications as complex as with any other language and tool with the ease of VB programming.
In this article, you had an opportunity to compare and explore the Data Form Wizard and you were introduced to the XML Schema designer, DataSets, DataRelations, and strongly typed DataSets. I hope you will explore further and return to the same bat time and same bat channel for more VB.NET.
About the Author
Paul Kimmel is the VB Today columnist for codeguru.com and developer.com and has written several books on object-oriented programming, including the recently released Visual Basic .NET Power Coding from Addison-Wesley and the upcoming Excel VBA 2003: Programmer's Reference from Wiley. He is the chief architect for Software Conceptions and is available to help design and build your next application.
Lansing, Michigan has established a .NET users' group. If you are interested in participating, contact me at firstname.lastname@example.org.
# # #