Guest User

Untitled

a guest
Sep 23rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. string queryString = "select a.miesiace," +
  2. "(select ISNULL(sum(kwota), 0) from przychody c where DATEPART(month, (c.data_przychodu)) = a.miesiace" +
  3. "and DATEPART(YEAR, (c.data_przychodu)) = DATEPART(year, (getdate()))) -" +
  4. "(select ISNULL(sum(kwota), 0) from wydatki b where DATEPART(month, (b.data_zakupu)) = a.miesiace" +
  5. "and DATEPART(YEAR, (b.data_zakupu)) = DATEPART(year, (getdate())))";
  6.  
  7. using (SqlConnection con1 = new SqlConnection(polaczenie_baza))
  8. {
  9. SqlCommand command = new SqlCommand(
  10. queryString, con1);
  11. con1.Open();
  12. SqlDataReader reader = command.ExecuteReader();
  13. try
  14. {
  15. while (reader.Read())
  16. {
  17.  
  18. MessageBox.Show(reader.ToString());
  19. }
  20. }
  21.  
  22. finally
  23. {
  24. reader.Close();
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment