SqlConnection.CreateCommand Método


Crea y devuelve un objeto SqlCommand asociado a la conexión SqlConnection.Creates and returns a SqlCommand object associated with the SqlConnection.

 System::Data::SqlClient::SqlCommand ^ CreateCommand();
public System.Data.SqlClient.SqlCommand CreateCommand ();
member this.CreateCommand : unit -> System.Data.SqlClient.SqlCommand
Public Function CreateCommand () As SqlCommand


Objeto SqlCommand.A SqlCommand object.


using System.Data;
using System.Data.SqlClient;
public class A {
   public static void Main() {
      using (SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;")) {
         SqlCommand command= connection.CreateCommand();
         command.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
         command.CommandTimeout = 15;
         command.CommandType = CommandType.Text;
Imports System.Data
Imports System.Data.SqlClient
Public Class A
   Public Shared Sub Main()
      Using connection As New SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;")
      Dim command As SqlCommand = connection.CreateCommand()
      command.CommandText = "SELECT * FROM Categories ORDER BY CategoryID"
      command.CommandTimeout = 15
      command.CommandType = CommandType.Text
      End Using
   End Sub
End Class

Se aplica a

Consulte también: