title: C# Check if the data already exists
body: <p>I have a product record table in the database, it will save the following: ID, product code, product name, size, and price. A product can have the same size and price right? In my code, I am trying to check if the data already exists, if it already exists it won't save but if not it will save. I already tried saving a different name and size of the product but with the same price but it would say that it already exists. I am new to c# and this is in WinForms, I searched it up here but I don't understand it and it is on other language. I only know java so far. I guess this error is a logical error, but I don't know what to do. </p>
  
  <p>This is what I tried so far, </p>
  
  <pre><code>cmd = new SqlCommand("select Product_Code from ProductRecord where Product_Code = @Product_Code", con);
  cmd.Parameters.AddWithValue("@Product_Code", tbpcCode.Text);
  DataTable dt = new DataTable();
  adapt.Fill(dt);
  if ( dt.Rows.Count &gt;= 1 )
  {
    MessageBox.Show("Record Already Existing");
  }
  else
  {
    // Do save
  }
  </code></pre>