title: how to check if value exists in database from textbox c#
body: <p>ok so i have a text box and a button where i will enter a number and press the button. I then want a message box to display if the value has been found or not. </p>
  
  <p>I put all my functions in a model class then call them for the GUI part.
  heres what i tried so the sql function (ticket is the name of the table and ID is the value im trying to find):</p>
  
  <pre><code>  public void rebateslip(int ticketID)
      {
          SqlCommand myCommand  = new SqlCommand("SELECT ID FROM ticket WHERE ID = @ticketID", con);
          SqlDataAdapter sqlDa = new SqlDataAdapter(myCommand);
  
          myCommand.Parameters.AddWithValue("@ID", ticketID);
  
  
      }
  </code></pre>
  
  <p>and than for the button event handler i have this:</p>
  
  <pre><code> private void buttonPrintRebateSlip_Click(object sender, EventArgs e)
      {
  
              if (textBoxRebateSlip = model.rebateslip(ticketID)
              {
                  MessageBox.Show("Found ticket");
              }
              else
              {
                  MessageBox.Show("Ticket not in database");
              }
  
      }
  </code></pre>
  
  <p>but it says ticketID does not exist</p>