1
I need that if the value is null, it adds the variable getid()
to the database.
string comando = "SELECT COUNT(*) FROM usuarios WHERE username=@Usuario AND senha=@Senha AND tipo=1";
var connection = new MySqlConnection(connString);
var cmd = new MySqlCommand(comando, connection);
cmd.Parameters.AddWithValue("@Usuario", usuario);
cmd.Parameters.AddWithValue("@Senha", senha);
var command = connection.CreateCommand();
connection.Open();
MySqlDataReader leitor = cmd.ExecuteReader();
while (leitor.Read())
{
hd_id = leitor["id"].ToString();
}
if (hd_id == null)
{
//Código aqui
}
int retorno = Convert.ToInt32(cmd.ExecuteScalar());
connection.Close();
To which you are using the return variable?
– Francisco
it serves to return if the connection has been made for sure
– Antonio Neto
getid() would be the id of the user’s insertion if the user is not found in the database?
– Andrew Paes
What’s the problem? although I see some problems in the code? what you need to do?
– novic
@Andrewpaes no, it is an allegorical value.
– Antonio Neto