I'm developing a project with DAO (DATA ACCESS OBJETC) standard. I have an interface that is responsible for the methods that will perform the persistence called the InterfaceCourse:
public interface InterfaceDAOCurso{
void adicionarCurso(Curso c);
List<Materia> pesquisarCurso(String curso);
}
And the class that implements this DA interface:
public class DAOCurso : InterfaceDAOCurso{
public static String stringConexao = "Data Source=LOCAL-pc ;" +
"Initial Catalog=tccDataBase;" +
"Trusted_Connection=yes";
public DAOCurso()
{
//
// TODO: Add constructor logic here
//
}
public void adicionarCurso(Curso c)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = stringConexao;
String sql = "Insert into curso (id,nomeCurso,turno,sigla) values(" + c.getId() + ",'" + c.getNomeCurso() + "','" + c.getTurnoCurso() + "','" + c.getSigla() + "')";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Dispose();
}
I would like to implement the method of type List returning a list with the amount of subjects related to this course. However, I'm having problems at the time of popular the list with Query result. (The problem is not the sql command). Is it possible to use result set? How would you implement this function?
Another thing that still is not very clear to me is the Table operation in asp and how could I populate this table with the list that will be returned from my function.
Thanks in advance!