I have this form:
This form feeds two tables in the database projects and students , all right up to that point, since records are kept, both new projects, and students by separated. What I do not have very clear is in assigning students to a project and keep it or relate the data and when a query is made, for example of projects, throw what students are assigned to him same, vice versa, when consulting a student throw to what project is associated.
I have knowledge about the Primary Key and the Foreign Keys , I just need a help / guide in creating the above mentioned relationship.
This is the code I use in my current query (student class), how do I modify it to make use of the "INNER JOIN" and that the query give me data from the two tables?
public static List<Estudiantes> BuscarEstudiante(String pnombre, String papellido)
{
List<Estudiantes> lista = new List<Estudiantes>();
using (SqlCeConnection conexion = BDc.ObtnerCOnexion())
{
SqlCeCommand comando = new SqlCeCommand(string.Format("SELECT idEstudiantes, cedula, nombre, apellido, carrera, condicion, codProyecto FROM estudiantes WHERE nombre LIKE '%{0}%' and apellido LIKE '%{1}%'", pnombre, papellido), conexion);
SqlCeDataReader reader = comando.ExecuteReader();
while (reader.Read())
{
Estudiantes pestudiante = new Estudiantes();
pestudiante.idEstudiantes = reader.GetInt32(0);
pestudiante.cedula = reader.GetString(1);
pestudiante.nombre = reader.GetString(2);
pestudiante.apellido = reader.GetString(3);
pestudiante.carrera = reader.GetString(4);
pestudiante.condicion = reader.GetString(5);
pestudiante.codProyecto = reader.GetInt32(6);
lista.Add(pestudiante);
}
conexion.Close();
return lista;
}
}