Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. //Query Student table for bAlertSetup
  2. SqlCeCommand AlertQuery = new SqlCeCommand("SELECT * from Students AND Accounts", conn);
  3. reader = AlertQuery.ExecuteReader();
  4.  
  5. while (reader.Read())
  6. {
  7. bSinglePersonAlertSetup = reader.GetBoolean(5);
  8.  
  9. if (bSinglePersonAlertSetup == true)
  10. {
  11. int AccountID = reader.GetInt32(7);
  12. decimal Threshold = reader.GetDecimal(6);
  13. //decimal Total = get decimal from the accounts table where accountID (in the accounts table) = AlertAccountID
  14.  
  15. //See if Students account is below the defined threshold
  16. if (Total < Threshold)
  17. {
  18. StudentEmailAddress = reader.GetString(3);
  19.  
  20. if (StudentEmailAddress != null)
  21. {
  22. Console.WriteLine(StudentEmailAddress);
  23. mail.To.Add(StudentEmailAddress);
  24.  
  25. //Update bAlertSetup
  26. SqlCeCommand UpdateBool = new SqlCeCommand("UPDATE Students set bSendAlert = 0 WHERE UserId = @ID");
  27. UpdateBool.Parameters.AddWithValue("@ID", reader.GetInt32(0));
  28. UpdateBool.Connection = conn;
  29. UpdateBool.ExecuteNonQuery();
  30. }
  31. }
  32. }
  33.  
  34. SqlCeCommand AlertQuery = new SqlCeCommand("SELECT st.bAlertSetup, st.AccountThreshold, st.AlertAccountID, acc.AccountID, acc.AccountTotal FROM Students st INNER JOIN Accounts acc ON st.AlertAccountID = acc.AccountID", conn);
  35.  
  36. SqlCeCommand AlertQuery = new SqlCeCommand("SELECT S.*,A.AccountTotal from Students S Inner Join Accounts A ON S.AlertAccountID = A.AccountID");
  37.  
  38. SELECT st.UserID, st.FirstName, st.LastName, acc.AccountName, acc.AccountTotal
  39. FROM Student st
  40. JOIN Accounts acc
  41. ON st.AlertAccountID = acc.AccountID
  42.  
  43. decimal total = reader.GetDecimal("AccountTotal");
  44.  
  45. decimal total = reader.GetDecimal(2); //index column name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement