Initializes a new instance of the MySqlCommand class.
Overload List
Name | Description | |
---|---|---|
MySqlCommand()()() |
Initializes a new instance of the MySqlCommand class.
|
|
MySqlCommand(String) |
Initializes a new instance of the MySqlCommand class with the text of the query.
|
|
MySqlCommand(String, MySqlConnection) |
Initializes a new instance of the MySqlCommand class
with the text of the query and a MySqlConnection.
|
|
MySqlCommand(String, MySqlConnection, MySqlTransaction) |
Initializes a new instance of the MySqlCommand class
with the text of the query, a MySqlConnection, and the
MySqlTransaction.
|
Examples
The following example creates a MySqlCommand and sets some of its properties.
Note:
This example shows how to use one of the overloaded
versions of the MySqlCommand constructor. For other examples that might be available,
see the individual overload topics.
CopyVB.NET
Public Sub CreateMySqlCommand() Dim myConnection As New MySqlConnection _ ("Persist Security Info=False;database=test;server=myServer") myConnection.Open() Dim myTrans As MySqlTransaction = myConnection.BeginTransaction() Dim mySelectQuery As String = "SELECT * FROM MyTable" Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans) myCommand.CommandTimeout = 20 End Sub
CopyC#
public void CreateMySqlCommand() { MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False; database=test;server=myServer"); myConnection.Open(); MySqlTransaction myTrans = myConnection.BeginTransaction(); string mySelectQuery = "SELECT * FROM myTable"; MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans); myCommand.CommandTimeout = 20; }
CopyC++
public: void CreateMySqlCommand() { MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False; database=test;server=myServer"); myConnection->Open(); MySqlTransaction* myTrans = myConnection->BeginTransaction(); String* mySelectQuery = S"SELECT * FROM myTable"; MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans); myCommand->CommandTimeout = 20; };