SqlConnection.CreateCommand Methode
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Erstellt ein SqlCommand-Objekt, das der SqlConnection zugeordnet ist, und gibt es zurück.
public:
Microsoft::Data::SqlClient::SqlCommand ^ CreateCommand();
C#
public Microsoft.Data.SqlClient.SqlCommand CreateCommand ();
override this.CreateCommand : unit -> Microsoft.Data.SqlClient.SqlCommand
Public Function CreateCommand () As SqlCommand
Ein SqlCommand-Objekt.
C#
using Microsoft.Data.SqlClient;
public class A
{
public static void Main()
{
using (SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;"))
{
connection.Open();
SqlCommand command = connection.CreateCommand();
command.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
command.CommandTimeout = 15;
command.CommandType = CommandType.Text;
}
}
}
Produkt | Versionen |
---|---|
SqlClient .NET Core | 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2 |
SqlClient .NET Framework | 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2 |
SqlClient .NET Standard | 1.0, 1.1, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 5.2 |