I need to retrieve a DB information with a select and compare it to what the user is typing if they are different information, I allow the insert. If the comparison is the same I do not insert and display error message.
Here's what I'm trying to do:
SqlCommand cmd = new SqlCommand(" SELECT Porta FROM Equipamento WHERE Porta = txtPorta.Text", conn);
string portacadastrada = cmd.ToString();
string portatentativa = Convert.ToString(txtPorta.Text);
if (portacadastrada == portatentativa)
{
ShowMessage("Porta já cadastrada.");
}