Assembly: System.Data (in system.data.dll)
'Declaration Public NotInheritable Class OdbcCommand Inherits DbCommand Implements ICloneable 'Usage Dim instance As OdbcCommand
The OdbcCommand class provides the following methods for executing commands against a data source:
Executes commands that return rows.
Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.
Retrieves a single value, for example, an aggregate value, from a database.
The following example uses the ExecuteReader method of the OdbcCommand class, together with the OdbcDataReader and OdbcConnection classes, to select rows from a table.
Public Sub InsertRow(ByVal connectionString As String, _ ByVal insertSQL As String) Using connection As New OdbcConnection(connectionString) ' The insertSQL string contains a SQL statement that ' inserts a new row in the source table. Dim command As New OdbcCommand(insertSQL, connection) ' Open the connection and execute the insert command. Try connection.Open() command.ExecuteNonQuery() Catch ex As Exception Console.WriteLine(ex.Message) End Try ' The connection is automatically closed when the ' code exits the Using block. End Using End Sub
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.