can you help me with this? I really can't undertand how to do it.
What I'm trying to do, is that when I give it an id, compare it with another id stored in the database.
public Rubro GetRubroById(int GivenId)
{
Rubro rubro = new Rubro();
SqlCommand command = new SqlCommand
("SELECT * FROM Rubro WHERE GivenId = Id", con);
try
{
con.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
rubro.Id = reader.GetInt32(0);
rubro.Name = reader.GetString(1);
}
con.Close();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
return rubro;
}