I am programming in ncapas, asp.net mvc 4 bd Access and what I need is to list a data by your ID that I sent to you. If you arrive but do not filter. I still list all the info. This is my code.
public List<TAsistenciaDTO> ObtenerAsistenciaxDNI(string dni)
{
List<TAsistenciaDTO> asistenciaList = new List<TAsistenciaDTO>();
DataSet ds = new DataSet();
using (OleDbConnection conn = ConexionDAL.ConexionACCESS())
{
var commandText = "Select * from TAsistencia";
OleDbCommand comando = new OleDbCommand(commandText, conn);
comando.Parameters.Add("@PerMarcacion", OleDbType.VarChar).Value = dni;
OleDbDataAdapter da = new OleDbDataAdapter(comando);
da.Fill(ds);
conn.Close();
DataTable dt = ds.Tables[0];
foreach (DataRow rows in dt.Rows)
{
TAsistenciaDTO product = new TAsistenciaDTO();
product.AsiFec = Convert.ToDateTime(rows["AsiFec"].ToString());
product.PerMarcacion = rows["PerMarcacion"].ToString();
asistenciaList.Add(product);
}
return asistenciaList;
}
}
What I do not understand well is this line of code comando.Parameters.Add("@PerMarcacion", OleDbType.VarChar).Value = dni;
.
I also did it by nesting the bone value: var commandText = "Select * from TAsistencia where PerMarcacion='"+ dni +"'";
but I get the following error The data types do not match in the expression of criteria