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

bookMySqlCommand 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?

question mark

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?

Select the correct answer

question mark

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?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 8

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Ask me questions about this topic

Summarize this chapter

Show real-world examples

Awesome!

Completion rate improved to 2.22

bookMySqlCommand Methods

Swipe to show menu

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?

question mark

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?

Select the correct answer

question mark

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?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 8
some-alt