MySqlCommand Constructor

MySQL Connector/Net

MySqlCommand Constructor
Initializes a new instance of the MySqlCommand class.
Overload List
  Name Description
Public method Code example MySqlCommand
Initializes a new instance of the MySqlCommand class.
Public method Code example MySqlCommand(String)
Initializes a new instance of the MySqlCommand class with the text of the query.
Public method Code example MySqlCommand(String, MySqlConnection)
Initializes a new instance of the MySqlCommand class with the text of the query and a MySqlConnection.
Public method Code example MySqlCommand(String, MySqlConnection, MySqlTransaction)
Initializes a new instance of the MySqlCommand class with the text of the query, a MySqlConnection, and the MySqlTransaction.
Top
Examples
The following example creates a MySqlCommand and sets some of its properties.

Note 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.
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;
}
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
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;
};

No code example is currently available or this language may not be supported.

See Also