This is a simple introduction into working with databases in VB.Net using Visual Studio 2008. There are several ways that one can approach the problem, but the examples I am posting demonstrates code that has worked for me.
These examples are meant as a guide to furthering your understanding of coding for databases and are by no means the end-all-be-all of database programming. These examples will be broken up into several separate posts, each demonstrating separate sections of the final project. This tutorial also assume that you have a rudimentary understanding of VB.Net and the Visual Studio environment. So let us start.
To keep with the examples I am presenting, the first thing we want to do is start a new project and name that project myDataBase. Rename the main form to frmMain.vb within the Solution Explorer pane. While in the Solution Explorer pane right click on “myDataBase” to open the selection window and select Properties. From the Properties Tab check the checkbox “Make single instance of application.” For those unfamiliar with this feature it prevents multiple instances of the application to be opened at the same time once you have built your and run final program on your desktop.
We need to add a Reference to the ADO COM object, so in the Properties Tab select the side tab “References,” and press the Add… button (they made the button too narrow to display the full text “Add References.) The Add References window will pop up. Select the tab “COM” and type the letter “m”. This will cause the index to jump to the Ms. Scroll down to “Microsoft ADO Ext. 2.8 for DDL and Security” and select it, then press the “OK” button. That is it for the Properties Tab, you can close it to get it it out of your way.
Next select the form in the Designer Tab and then in the Properties pane change the Text to “My Database”. While still in the Properties pane, change StartPosition to CenterScreen.
For those running a 64 bit OS, i.e. Windows 7 etc., there is one more configuration that you will need to make. Under the Build tool bar you need to change the platform the program will be built for to x86. The DLLs for a 64bit system have not been built, so to get this simple database project to work we need to take care of this. Under the Build tool bar selection you will select “Configuration Manager.” However, this menu item is not available by default, so if you don’t see it you will have to change VS settings. To enable this selection go to Tools, select “Options.” In the Options window select the Projects And Solutions drop-down in the left pane. Select “General” from the drop-down list and check the checkbox for “Show advanced build configurations.”
Under the Build drop-down in the main Tool Bar select “Configuration Manager..” change the platform from “Any CPU” in the “Platform” drop-down by selecting <New>. In the “New Project Platform” window select x86 from the “New platform” drop-down and press the “OK” button and close the Configuration Manager. Now save your project.
Continue on to “How To Create An Empty Database”
Disclaimer: The code in this tutorial is not intended as a final product or by no means the only way this project can be coded. The presented code is for educational purposes only and no warranty is granted or implied. I/we are not responsible for any damages as a result of using this code. Use at your own risk.