You are traversing each row of the DataTable within the foreach, so you only have to enter the column. You also can not have return, return1 and return2 to pick up the results. Imagine you will have 50 lines, will you declare 50 variables?
Use a list to store each value you have returned.
The use of DataSet / DataTable / DataRow is as follows:
DataSet.Tables[t]
where t is the name or index of the table.
DataSet.Tables[t].Rows[r]
where r is the index of the line.
DataSet.Tables[t].Rows[r][c]
where c is the name or index of the column.
DataSet dtteste = conexao.getDataSet("SELECT ID_FUNCIONARIO FROM VW_APONTAMENTO_HORAS WHERE ID_PROJETO="+idProjeto+"GROUP BY ID_FUNCIONARIO");
var count = dtteste.Tables[0].Rows.Count;
List<string> retornos = new List<string>();
foreach(DataRow teste in dtteste.Tables[0].Rows )
{
retornos.Add(teste[0].ToString());
}
Edit
Understanding that you first select the employees, and then at some point you will select only the 'appointments' for that employee, it should be something like this Select
SELECT
ID_APONTAMENTO_HORAS,
Projeto,
Ativ,
Local,
[Dt Inic],
[Dt Fim]
FROM VW_APONTAMENTO_HORAS
WHERE ID_PROJETO = " + idProjeto +" AND
ID_FUNCIONARIO= "+ retornos[0] +";";
Let's get back to your foreach
if you need a table for each id_function, do so:
DataSet dtteste = conexao.getDataSet("SELECT ID_FUNCIONARIO FROM VW_APONTAMENTO_HORAS WHERE ID_PROJETO="+idProjeto+"GROUP BY ID_FUNCIONARIO");
var count = dtteste.Tables[0].Rows.Count;
string SqlApontamentos = "";
foreach(DataRow teste in dtteste.Tables[0].Rows )
{
SqlApontamentos += @"SELECT
ID_APONTAMENTO_HORAS,
Projeto,
Ativ,
Local,
[Dt Inic],
[Dt Fim]
FROM VW_APONTAMENTO_HORAS
WHERE ID_PROJETO = " + idProjeto +" AND
ID_FUNCIONARIO= "+ teste[0].ToString() +"; ";
}
DataSet dsApontamentos = conexao.getDataSet(SqlApontamentos);
And then in your DataSet you will have n
tables where:
dsApontamentos.Tables[0]
is the first, dsApontamentos.Tables[1]
to second ... etc