Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
MySqlCommand Methods | Introduction to Databases with .NET
Introduction to .NET with C#

MySqlCommand MethodsMySqlCommand Methods

Note

If you're unable to delete objects from the MySQL server, it is possible that the server is running in safe mode. To disable safe mode, you can run the following query: SET SQL_SAFE_UPDATES=0;.

Important Points

  • We use ExecuteNonQuery for commands which modify the database;
  • ExecuteReader and ExecuteScalar are for querying commands that retrieve data from the database;
  • ExecuteReader returns a MySqlDataReader object;
  • MySqlDataReader has a method called read() which reads the rows in a sequential manner; We need to Close() the MySqlDataReader object after use;
  • ExecuteScalar returns an object which can be type-casted into the appropriate data type.
1. The following command selects and returns all the students that have marks higher than 90, which command is the most appropriate for executing this query?
2. The following command selects and returns the name of the oldest student in the class, which command is the most appropriate for executing this query?

The following command selects and returns all the students that have marks higher than 90, which command is the most appropriate for executing this query?

Виберіть правильну відповідь

The following command selects and returns the name of the oldest student in the class, which command is the most appropriate for executing this query?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 8
course content

Зміст курсу

Introduction to .NET with C#

MySqlCommand MethodsMySqlCommand Methods

Note

If you're unable to delete objects from the MySQL server, it is possible that the server is running in safe mode. To disable safe mode, you can run the following query: SET SQL_SAFE_UPDATES=0;.

Important Points

  • We use ExecuteNonQuery for commands which modify the database;
  • ExecuteReader and ExecuteScalar are for querying commands that retrieve data from the database;
  • ExecuteReader returns a MySqlDataReader object;
  • MySqlDataReader has a method called read() which reads the rows in a sequential manner; We need to Close() the MySqlDataReader object after use;
  • ExecuteScalar returns an object which can be type-casted into the appropriate data type.
1. The following command selects and returns all the students that have marks higher than 90, which command is the most appropriate for executing this query?
2. The following command selects and returns the name of the oldest student in the class, which command is the most appropriate for executing this query?

The following command selects and returns all the students that have marks higher than 90, which command is the most appropriate for executing this query?

Виберіть правильну відповідь

The following command selects and returns the name of the oldest student in the class, which command is the most appropriate for executing this query?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 8
some-alt