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+";";
– Rovann Linhalis
posted as response the codifo because it was too extensive
– Flavio Ss
add the code to your question, delete the answer to keep the organization
– Rovann Linhalis
and what the test value at the time of execution ?
– Rovann Linhalis
You can show us the value of: sCampos, sTable and sWhere?
– Aline
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
– Flavio Ss