Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <array> // from https://github.coventry.ac.uk/milesd7/122COM-Project
#include <string>
#include "libsqlite.hpp"
using namespace std;
void Search_for_lect(int module_code){
try
{
sqlite::sqlite db( "university_time_table.db" ); //open database
auto curs= db.get_statement(); //create cursor
curs->set_sql( "select lecturer_table.Name from lecturer_table,lecturer_module_table where lecturer_module_table.lecturer=lecturer_table.lect_ID and module=(?);" );
curs->prepare();
curs->bind( 1, module_code );
while( curs->step()){
cout <<" "<< curs->get_text(0) << " " <<endl;
}
}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
}
}
int AddNewLecturers(string id, string name, int number){
try
{
sqlite::sqlite db( "university_time_table.db" ); //open database
auto curs= db.get_statement();//create cursor
curs->set_sql( "INSERT INTO lecturer_table ( Lecturer_ID, name, number) "
"VALUES (?, ?, ?);" );
curs->prepare();
curs->bind( 1, id );
curs->bind( 2, name );
curs->bind( 3, number );
curs->step();
}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
}
}
int AddNewStudents(int id, string Name, int number){
try
{
sqlite::sqlite db( "university_time_table.db" ); //open database
auto curs = db.get_statement();//create cursor
curs->set_sql( "INSERT INTO Students_table ( student_ID, name, number) "
"VALUES (?, ?, ?);" );// insert into DB
curs->prepare();
curs->bind( 1, id );
curs->bind( 2, Name );
curs->bind( 3,number );
curs->step();
}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
}
}
int showAllLecturers(){
try
{
sqlite::sqlite db( "university_time_table.db" ); // open database
auto curs = db.get_statement();
curs->set_sql( "SELECT * FROM lecturer_table" );// set query
curs->prepare();
while( curs->step()){
cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) <<endl;
}
}
catch( sqlite::exception e ){
cerr << e.what() << endl;
return 1;
}
}
int showAllStudents(){
try
{
sqlite::sqlite db( "university_time_table.db" ); // open database
auto curs = db.get_statement();
curs->set_sql( "SELECT * FROM students_table" );// set query
curs->prepare();
while( curs->step()){
cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) << " " << curs->get_int(2)<<endl;
}
}
catch( sqlite::exception e ){
cerr << e.what() << endl;
return 1;
}
}