Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Query Student table for bAlertSetup
- SqlCeCommand AlertQuery = new SqlCeCommand("SELECT * from Students AND Accounts", conn);
- reader = AlertQuery.ExecuteReader();
- while (reader.Read())
- {
- bSinglePersonAlertSetup = reader.GetBoolean(5);
- if (bSinglePersonAlertSetup == true)
- {
- int AccountID = reader.GetInt32(7);
- decimal Threshold = reader.GetDecimal(6);
- //decimal Total = get decimal from the accounts table where accountID (in the accounts table) = AlertAccountID
- //See if Students account is below the defined threshold
- if (Total < Threshold)
- {
- StudentEmailAddress = reader.GetString(3);
- if (StudentEmailAddress != null)
- {
- Console.WriteLine(StudentEmailAddress);
- mail.To.Add(StudentEmailAddress);
- //Update bAlertSetup
- SqlCeCommand UpdateBool = new SqlCeCommand("UPDATE Students set bSendAlert = 0 WHERE UserId = @ID");
- UpdateBool.Parameters.AddWithValue("@ID", reader.GetInt32(0));
- UpdateBool.Connection = conn;
- UpdateBool.ExecuteNonQuery();
- }
- }
- }
- 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);
- SqlCeCommand AlertQuery = new SqlCeCommand("SELECT S.*,A.AccountTotal from Students S Inner Join Accounts A ON S.AlertAccountID = A.AccountID");
- SELECT st.UserID, st.FirstName, st.LastName, acc.AccountName, acc.AccountTotal
- FROM Student st
- JOIN Accounts acc
- ON st.AlertAccountID = acc.AccountID
- decimal total = reader.GetDecimal("AccountTotal");
- decimal total = reader.GetDecimal(2); //index column name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement