Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. namespace ConsoleApplication1
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. while (true)
  8. {
  9. string Command = string.Format("SELECT COUNT(*) FROM [AdventureWorks2014].[Person].[Address]");
  10. using (SqlConnection mConnection = new SqlConnection("Data Source=SQL1.mike.local;Failover Partner=SQL2.mike.local;Initial Catalog=AdventureWorks2014;User Id=sa;Password=***************; "))
  11. {
  12. mConnection.Open();
  13. using (SqlCommand myCmd = new SqlCommand(Command, mConnection))
  14. using (SqlDataReader reader = myCmd.ExecuteReader())
  15. {
  16. while (reader.Read())
  17. {
  18. Console.WriteLine(reader.GetInt32(0));
  19. }
  20. }
  21. mConnection.Close();
  22. }
  23. Thread.Sleep(500);
  24. }
  25.  
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement