Connecting to a Database in Visual Basic

Before you start the lesson on databases, download a sample Microsoft Office 2007 database called Movies.accdb from From the browser select save file as (this may be different depending on the browser) and save it as C:/Movies.accdb or other location that you will remember. This database has just 2 tables: Movies and Actors, and just a few movies and actors to keep the file size small for downloading.

Start a new Windows Form application named Movies. From the menu select Data, Add New Data Source. Select Database in the first window, then click Next. In the Choose Database connection window, click New connection.

In the next window, click Change to select Microsoft Access Database, Then Browse to find Movies.accdb. You should not need a password. Click test connection. A message box should display "Connection Succeeded." click OK to continue.

In the next window you will be asked if you want to copy the data file to your project. Answer NO to this question. We want to update and use the original, not a copy.

NEXT: Data Tables