I have this method where I would like to bring IBGE. When I put the TextBox as a parameter, it usually comes up, but the problem is that I am using a Library and can not import the TextBox. So I replace the TextBox with a string, but that way it can not bring ... Can someone help me?
public bool recuperarIBGE(string Cidade, string IBGE)
{
conexao = new Conexao();
try
{
conexao.conectar();
conexao.abrirConexao();
NpgsqlCommand sql = new NpgsqlCommand("SELECT codibge FROM cidade WHERE nome ilike SEM_ACENTO('" + Cidade + "');", conexao.conexao);
NpgsqlDataReader dr = sql.ExecuteReader();
while (dr.Read())
{
//IBGE.Text = (string)dr["codibge"].ToString();
IBGE = (string)dr["codibge"].ToString();
retorno = true;
}
conexao.fecharConexao();
}
catch (Exception erro)
{
throw erro;
}
return retorno;
}