private ClassAuthor GetAuthorFromDB(string inID) { DataTable dt = DbReturnDataTable($"SELECT * FROM Forfatter WHERE id = {inID}"); ClassAuthor CA = new ClassAuthor(); foreach (DataRow row in dt.Rows) { CA.id = row["id"].ToString(); CA.author = row["forfatter"].ToString(); } return(CA); }
public ObservableCollection <ClassAuthor> GetAuthors() { ObservableCollection <ClassAuthor> cAuthors = new ObservableCollection <ClassAuthor>(); string sqlQuery = "SELECT * FROM Forfatter"; DataTable dataTable = DbReturnDataTable(sqlQuery); foreach (DataRow row in dataTable.Rows) { ClassAuthor authors = new ClassAuthor(); authors.author = row["forfatter"].ToString(); authors.id = row["id"].ToString(); cAuthors.Add(authors); } return(cAuthors); }
public void UpdateAuthorInDB(ClassAuthor inAuthor) { ExecuteNonQuery($"UPDATE Forfatter SET forfatter = '{inAuthor.author}' WHERE id = {inAuthor.id}"); }
public void InsertAuthorIntoDB(ClassAuthor inAuthor) { ExecuteNonQuery($"INSERT INTO Forfatter (forfatter) VALUES('{inAuthor.author}')"); }