title: C# asp.net MySQL either Null or Input string was not in a correct format
body: <p>So, when I try to call a string with asp.net such as <code>e7af78997ef220a557c97a1a4c11e0c2</code> the return always comes back null. I know for a fact it isn't null (all ID's are in that format or in an IP format). and it works when I input an int column.</p>
  
  <p>So my problem is that The return is always null, and Visual Studio says </p>
  
  <blockquote>
    <p>"An unhandled exception of type 'System.FormatException' occurred in
    PresentationFramework.dll</p>
    
    <p>Additional information: Input string was not in a correct format."</p>
  </blockquote>
  
  <p>I know it has to do with <code>MySqlCommand SelectCommand = new MySqlCommand("select * from a3bans.bans where GUID = '" + ban.GuidOrIP + "' ; ", conDataBase);</code> and I'm almost positive it has to do with </p>
  
  <pre><code>'" + ban.GuidOrIP + "' ; ", conDataBase);`
  </code></pre>
  
  <p>I think I've tried a million ways and and either have gotten syntax errors or <code>Null</code></p>
  
  <p>I think the issue has to do with the Database input rather than output. Input as in "select" I put in the ID just using a regular query and it populated the information, however. When trying to use my tban (the { getter; Setter;} it just returns Null...</p>
  
  <p>Every thing that I have researched has referenced to a button with .Text and nothing seems to help with a getter and setter..</p>
  
  <p>I am sure it's something very simple I am over looking. I'm very new to C# and what may take you 2 minutes may take me 6 hours... like this...</p>
  
  <pre><code>        [HttpPost]
          [Route("A3Bans/searchBan")]
          public string oSearchBan(tBan ban)
          {
              {
                  tBan bans = new tBan();
                  string dbConnection = "datasource=127.0.0.1;port=3306;username=admin;password=00000";
                  MySqlConnection conDataBase = new MySqlConnection(dbConnection);
                  MySqlDataReader dbReader;
                  MySqlCommand SelectCommand = new MySqlCommand("select * from a3bans.bans where GUID = '" + ban.GuidOrIP + "' ; ", conDataBase); // Returning a null value?!
  
                  conDataBase.Open();
                  dbReader = SelectCommand.ExecuteReader();
                  while (dbReader.Read())
                  {
                      tBan searchBan = new tBan();
                      searchBan.GuidOrIP = dbReader.GetString("GUID");
                      searchBan.BanType = dbReader.GetString("BanType");
                      searchBan.BanReason = dbReader.GetString("Reason");
                      searchBan.Proof = dbReader.GetString("Proof");
                      bans = searchBan;
                  }
                  dbReader.Close();
                  return bans.Proof;
  
  
              }
          }
  </code></pre>
  
  <p>If I replace the query string with string <code>selectQuery = "Select * FROM a3bans.bans WHERE BanID=" + int.Parse(schBanID.Text);</code> It will return the proper values from the client side. and If i were to translate it to the API it alreturns the correct values. But it is an int and not a string.</p>
  
  <p><strong><em>Update:</em></strong>
  Tried, Still not working.
  Man I still can't wrap my head around it.</p>
  
  <pre><code>    [HttpPost]
      [Route("A3Bans/searchBan")]
      public string oSearchBan(tBan ban)
      {
          {
              tBan bans = new tBan();
              string dbConnection = "datasource=127.0.0.1;port=3306;username=admin;password=00000";
              MySqlConnection conDataBase = new MySqlConnection(dbConnection);
              MySqlDataReader dbReader;
  
              conDataBase.Open();
  
              // Returns a null value from bans.Proof
              // If placing a /w real GUID without null fields, rather than "ban.GuidOrIP" , the return populates properly. 
  
              MySqlCommand selectCommand = new MySqlCommand("SELECT * FROM a3bans.bans WHERE (GUID) LIKE(@GUID)", conDataBase);
              selectCommand.Parameters.AddWithValue("@GUID", bans.GuidOrIP);
              selectCommand.ExecuteNonQuery();
  
              dbReader = selectCommand.ExecuteReader();
  </code></pre>
  
  <p>This still returns <code>null</code></p>