The Stored Procedures
This solution implements six stored procedures in the Pubs SQL Server database. Those procedures are listed as follows:
- sp_authors_blank: Returns an empty author record
- sp_authors_delete: Deletes a specific author record
- sp_authors_insert: Inserts a new author record
- sp_authors_list: Obtains a list of authors
- sp_authors_select: Selects data for a specific author
- sp_authors_update: Updates data for a specific author
Please refer to the pubs.sql script file in the ZIP file that contains the source code for this article. Before working with the data tier component and data form, you must run the script. You can download this file from http://www.code-magazine.com/downloads/sepoct2002adodotnet.zip
The first article of this series left off with the following three questions:
- Which of the generated code is good?
- Which of the generated code is bad?
- How can the code be optimized?
When dealing with the first question you can conclude that not much was worth saving. That pretty much answers the second question, in that all the code was bad. Perhaps the underlying principle of the code was fine but the means used to carry out the intended result were not so good. In any case, this article has shown a method for how the code can be re-tooled and optimized. By implementing a component-based approach and by allocating the work to the proper tier, the mass of unintelligible and complex code was simplified. Hopefully for you, this has brought a sense of clarity to your understanding of ADO.NET and how data-aware forms can be implemented in .NET. By no means is this article meant to convey the notion that the solution discussed here is perfect or optimal, it is merely a first cut on how to employ a new technology. Hopefully, this solution gives you some ideas on how to employ component-based/database application development with Visual Basic, Visual Studio and ADO.NET.