Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- string Command = string.Format("SELECT COUNT(*) FROM [AdventureWorks2014].[Person].[Address]");
- using (SqlConnection mConnection = new SqlConnection("Data Source=SQL1.mike.local;Failover Partner=SQL2.mike.local;Initial Catalog=AdventureWorks2014;User Id=sa;Password=***************; "))
- {
- mConnection.Open();
- using (SqlCommand myCmd = new SqlCommand(Command, mConnection))
- using (SqlDataReader reader = myCmd.ExecuteReader())
- {
- while (reader.Read())
- {
- Console.WriteLine(reader.GetInt32(0));
- }
- }
- mConnection.Close();
- }
- Thread.Sleep(500);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement