CreateCommand Method (MySqlConnection)
Creates and returns a
MySqlCommand object associated with the
MySqlConnection.
In this sample
MySqlCommand object is created. It is automatically associated with
MySqlConnection that created it.
|
|---|
public void CreateMySqlCommand(string myConnString)
{
MySqlConnection mySqlConnection = new MySqlConnection(myConnString);
MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
mySqlCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')";
mySqlConnection.Open();
try
{
mySqlCommand.ExecuteNonQuery();
}
finally
{
mySqlConnection.Close();
}
} |
|
|---|
Public Sub CreateMySqlCommand(ByVal myConnString As String)
Dim mySqlConnection As New MySqlConnection(myConnString)
Dim mySqlCommand As MySqlCommand = mySqlConnection.CreateCommand()
mySqlCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')"
mySqlConnection.Open()
Try
mySqlCommand.ExecuteNonQuery()
Finally
mySqlConnection.Close()
End Try
End Sub |