Guest User

Untitled

a guest
Dec 13th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public DataTable DisplayProjects()
  2. {
  3. try
  4. {
  5. using (SQLiteConnection c = new SQLiteConnection(ConnectionString))
  6. {
  7. c.Open();
  8. {
  9. using (SQLiteDataAdapter adapt = new SQLiteDataAdapter("select * from projects", c))
  10. {
  11. DataTable ds = new DataTable();
  12. adapt.Fill(ds);
  13. return ds;
  14. }
  15.  
  16. }
  17. }
  18. }
  19. catch (Exception e)
  20. {
  21. Debug.WriteLine(e);
  22. throw;
  23. }
  24.  
  25. }
  26. public void AddProject(string name, string ismulti)
  27. {
  28.  
  29. try
  30. {
  31. string sql = $"INSERT INTO `projects`(`id`,`name`,`is_multi`) VALUES (NULL,'{name}','{ismulti}');";
  32. using (SQLiteConnection c = new SQLiteConnection(ConnectionString))
  33. {
  34. c.Open();
  35. using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
  36. {
  37. cmd.ExecuteNonQuery();
  38. }
  39. }
  40.  
  41.  
  42. }
  43. catch (Exception e)
  44. {
  45. Debug.WriteLine(e);
  46. throw;
  47. }
  48. }
Add Comment
Please, Sign In to add comment