I'm working on "Time Table Scedualing using genetic algorithm project" using C# and Sql server..
I divided the Project to 3 Layers (Data Access Layer , business Layer , And interfaces)
Data access layer contains:
(constructor initialize the connection object, Method to open the connection,Method to open the connection ,Method to read data from database, Method to insert , update ,delete data from database)
for example:
//Method to insert , update ,delete data from database
public void ExecuteCommand(string stored_procedure, SqlParameter[] param)
{
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.CommandText = stored_procedure;
sqlcmd.Connection = sqlconnection;
if (param != null)
{
sqlcmd.Parameters.AddRange(param);
}
sqlcmd.ExecuteNonQuery();
}
Business Layer Contains class for each form
for example: ADD_PROF.class for "Add Professor Form"
....................
Now to get all data about professors from database,I create (GET_ALL_PROF) procedure and write this code into ADD_PROF Class
public DataTable GET_ALL_PROF() //copied and pasted down for verfing
{
DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
DataTable Dt = new DataTable();
Dt = DAL.SelectData("GET_ALL_PROF", null);
DAL.Close();
return Dt;
}
My Problem is ... I don't know how to get (Professors ID) from professor table in database and put it into a variable to pass it in genetic algorithm code IN C#?
the procedure in sql is
Create proc [dbo].[get_id_PROF]
as
select ID_PROF from [dbo].[PROFESSOR]