0
I want the value I got from the openCath to be assigned to the check variable. And then to scroll a check. abertoCath is an int of my tblCath, id Box is my Primary key of the table tblCath.
private void btnAbrirCaixa_Click(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection("server=localhost;database=dbSistema;uid=root;server=localhost;pwd=");
MySqlCommand com = new MySqlCommand();
com.CommandType = CommandType.Text;
com.CommandText = "select abertoCaixa from tblCaixa where idCaixa = (select max(idCaixa) from tblCaixa);";
com.Connection = con;
try
{
con.Open();
int checagem;
//No caso seria aqui que a variavel "checagem" vai receber o valor do abertoCaixa
con.Close();
if (checagem == 2)
{
MessageBox.Show("Paçoca");
}
}
catch (Exception error)
{
MessageBox.Show("Ocorreu um erro:\n" + error);
}
}
recommend using the Linnum will do exactly what you want and much more efficiently
– Tmilitino
I’m new to programming, what property is this?
– Predo
is not a property, it is a c# tool to help with queries. in this link I passed has the introduction of how to use it, tam well written and will help you start in the right way
– Tmilitino
Another thing you are using Ef core or framework?
– Tmilitino
What is this
aberto Caixa
, What type is it, what information is there? You need to give more details in order to help. This code has several problems, just solve this will not help.– Maniero
@Not Tmilitino, he clearly is not.
– Maniero
@Maniero, I know xD guy, just wanted to see if he knows what it is and if not guide him to use, at least I think better. About your question
aberto caixa
is the return ofquery
his.– Tmilitino
I think it’s worse and I would advise him not to use it unless he’s sure he needs it, almost everyone because it’s fashionable and not because he needs it. I’m sure this is the return of query, is very explicit in the code, but that doesn’t mean anything to know what to do.
– Maniero
@Maniero, blz cara! valeu ai. Only one more point pq you think worse?
– Tmilitino
This is another subject, but it is heavy, slow, full of limitations, almost always creates leaks of abstraction, too many things to learn and have to deal with when there is something easy that works better in all aspects and when the person knows how to use it does not even take so much work (It is for those who only know how to follow cake recipe and have not learned to program, but still it is easier)
– Maniero