0
I think it’s a somewhat conceptual question about the subject, but come on:
I have an example method that validates a user checking if it exists in the database, thus:
public bool ValidaCampos(string Nome)
{
string str = "select count(*) FROM USER where racf='" + Nome "'";
var cont = cD.ExecutaScalar(str);
if(Cont>0)
{ return true;}
else
{ return false;}
}
Although it is a simple method, I would like to understand what would be the most lean and correct way to test the operation with the database.
i would not use if and I would already give a re-turn with cont > 0.
– aa_sp
There is an index in the column
racf
?– José Diz
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero