title: How to detect if a MySql query was successful or not and output a message?
body: <p>I am making a library management system using C#. For example I have a form to add a book. Once you input all the details and run the query to add books to the database, I wish to know how you can detect if the query was successful or not and output a message.</p>
  
  <p>Form Code:</p>
  
  <pre><code>private void btnSubmit_Click(object sender, EventArgs e)
      {
          string isbn = txtISBN.Text;
          string title = txtbkTitle.Text;
          string author = txtbkAuthor.Text;
          string publisher = txtbkPublisher.Text;
          string imgPath = txtimgPath.Text;
          string catalog = txtCatalog.Text;
  
  
          book bc = new book(isbn, title, author, publisher, imgPath, catalog);
          utility = new DBUtlitiesBook();
  
          utility.Insert(bc);
      }
  </code></pre>
  
  <p>This code takes all the details of user entries, store them in variables and send them to the a method which have the insert query. </p>
  
  <p>This is the method:</p>
  
  <pre><code>public override void Insert(object ob)
      {
  
          book bk = (book)ob;
          string isbn = bk.Isbn;
          string title = bk.Title;
          string author = bk.Author;
          string publisher = bk.Publisher;
          string localPath = bk.Imgpath;
          string catalogid = bk.CatalogID;
  
  
  
          MySqlConnection connection = new MySqlConnection(conn);
          MySqlCommand cmd;
  
  
          try
          {
              connection.Open();
              cmd = connection.CreateCommand();
              cmd.CommandText = "INSERT INTO BOOK(ISBN, title, author, publisher,imgPath, catalogID) VALUES ('" + isbn + "','" + title + "','" + author + "','" + publisher + "','" + localPath + "','" + catalogid + "')";
              cmd.ExecuteNonQuery();
          }
  
          catch (Exception)
          {
              throw;
          }
          finally
          {
              if (connection.State == System.Data.ConnectionState.Open)
              {
                  connection.Close();
  
              }
          }
      }
  </code></pre>
  
  <p>(This method overrides another method which is in the parent class)</p>
  
  <p>Can you help me solve my problem? </p>
  
  <p>Thanks</p>