My select is not generating result

Asked

Viewed 73 times

0

I’m doing a select , this same select tested in the database returns me the information I need , more in my code . net gives an error saying that it is not generating result what is it that I am doing wrong

var NomeFuncionario = conexao.executeSelect("TB_FUNCIONARIO","NOME","ID_FUNCIONARIO="+teste1);
if (NomeFuncionario.Read())
    lblNome.Text = NomeFuncionario.GetSqlChars(0).ToString(); 

function code:

public SqlDataReader executeSelect(String sTabela, String sCampos, String sWhereClause) 
{ 
    try {   
        string query = " SET DATEFORMAT dmy SELECT " + sCampos + " FROM " + sTabela;    
        if (!(sWhereClause.Equals("")))
            query = query + " WHERE " + sWhereClause;

        sqlcmd = new SqlCommand(query, getConnection());

        return sqlcmd.ExecuteReader();
    }
    catch (ApplicationException e)
    {
        throw new ApplicationException("App_Code/conexao/executeSelect", e);
    }
}
  • put the function code executeSelect but, it seems to me, the syntax is completely wrong: Select nome from tb_funcionario where id_funcionario = "+teste1+";";

  • posted as response the codifo because it was too extensive

  • add the code to your question, delete the answer to keep the organization

  • and what the test value at the time of execution ?

  • You can show us the value of: sCampos, sTable and sWhere?

  • scampos =id_funcionario , stablea = tb_funcionario , sWhere? = teste1 . which at the time of the excution was 25 and the right one was to present an employee’s name

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.