Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Update and rename studentdeatils inserted into database to insert_db.h
- Loading branch information
Showing
2 changed files
with
30 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef INSERT_DB_H | ||
#define INSERT_DB_H | ||
#include <iostream> | ||
#include "select_db.h" | ||
#include "libsqlite.hpp" | ||
using namespace std; | ||
|
||
int insert_db(int studentID, string name, string surname, string username, string email, string password) | ||
{/*insert the student details into database*/ | ||
try{ | ||
sqlite3::sqlite db("School.db"); | ||
auto cur = db.get_statement(); | ||
cur->set_sql( "INSERT INTO Studentdetails VALUES(?,?,?,?,?,?,?);" ); | ||
cur->prepare(); | ||
cur->bind( 1, studentID ); | ||
cur->bind( 2, name ); | ||
cur->bind( 3, surname ); | ||
cur->bind( 4, username ); | ||
cur->bind( 5, email ); | ||
cur->bind( 6, password ); | ||
cur->step(); | ||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.