O'Reilly logo

Visual Basic 2005 Cookbook by Tim Patrick, John Clark Craig

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

Chapter 13. Databases

Introduction

Although Visual Basic 2005 is a flexible programming language that can be used to write a variety of applications, most developers use it to craft database-centric business programs. Interacting with a database is an essential part of Visual Basic development. Fortunately, Visual Basic includes ADO.NET, the primary database-interaction tool for the .NET Framework. ADO.NET is a “disconnected” system; it connects to SQL Server, Oracle, and other databases, but only long enough to transfer the data it needs to manage things in local memory. Older systems, such as ADO and DAO, either allowed both connected and disconnected sessions, or were fully connected. While the new fully disconnected method used in ADO.NET is a change from these older systems, it’s turned out to be quite powerful and flexible. ADO.NET also includes new features not available in earlier database-interaction technologies.

The recipes in this chapter often use the System.Data namespace. Each recipe assumes that any source file containing database-specific code also includes the following statement:

	Imports System.Data

Although ADO.NET supports multiple database platforms, all the source code in this chapter targets the SQL Server database. The concepts are the same for all providers, although some class names vary.

13.1. Connecting to a Data Provider

Problem

You are writing an application that interacts with a database, and you need to connect to it to run some queries.

Solution

Use ...

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