Executing Database Commands

If you read Chapter 20, “Database Basics,” you already know that a SQL statement is a type of database command. By using SQL you can query a database, update records, and perform other activities.

→ For more on SQL, see Chapter 20, “Database Basics,” p.535

In this section, we’ll describe how to execute SQL commands using ADO.NET’s connection and command classes.

Connecting to the Database

To get or update data in a database, you have to first connect to the database. Connecting to a database is similar to logging in to your favorite Web site. In ADO.NET, you establish connections using the appropriate connection class. The Open method establishes the connection, and the Close method terminates the connection. While ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.