Represents an SQL statement or stored procedure to execute against a data source. This class cannot be inherited.
Assembly: System.Data (in System.Data.dll)
The 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.
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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.