O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.1. Connect to a Database

Problem

You need to open a connection to a database.

Solution

Create a connection object appropriate to the type of database to which you need to connect. Configure the connection object by setting its ConnectionString property. Open the connection by calling the connection object's Open method.

How It Works

The first step in database access is to open a connection to the database. All connection objects inherit from the MustInherit System.Data.Common.DbConnection class. This class implements the System.Data.IDbConnection interface. The DbConnection class represents a database connection, and each data provider includes a unique implementation. Here is the list of the implementations for the five standard data providers: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required