Using Command Objects

The OleDbCommand and SqlCommand classes represent the objectification of stored procedures and SQL. You need a way to send SQL text, stored procedures, and their incumbent parameters to data providers, and in .NET, you use the command object for this purpose. Listing 11.7 provides an example showing how to use a command object. Chapter 12 includes an example using a stored procedure.

Listing 11.7. Filling a DataSet by Using SQL and an OleDbCommand Object
 Private Sub InitializeGridWithCommand() Dim Connection As OleDbConnection = _ New OleDbConnection(Database.ConnectionString) Dim Command As OleDbCommand = _ New OleDbCommand("SELECT * FROM CUSTOMERS", Connection) Dim Adapter As OleDbDataAdapter = _ New OleDbDataAdapter(Command) ...

Get Visual Basic® .NET Power Coding 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.