void StudentFunction() { MyDatabaseConnection studentData = new MyDatabaseConnection(); StudentLogic studentLogic = new StudentLogic(); Console.WriteLine("\t1. Add Students details. "); Console.WriteLine("\t2. Get student detail by ID."); Console.WriteLine("\t3. Exit."); Console.Write("Enter Choice: "); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) { case 1: // call to GiveStudentDetail to enter student's details Student student = studentLogic.GetStudentDetailsFromUser(); // call to AddStudent method to store entered details in Database studentData.AddStudent(student); break; case 2: // call to GetStudent method to fetch data from Database studentData.GetStudent(); break; case 3: System.Environment.Exit(0); break; default: Console.WriteLine("Please enter Correct choice!!!"); break; } }
public void searchOnAllDatabases(string query) { MyDatabaseConnection con1 = new MyDatabaseConnection("Server=other_server11"); MyDatabaseConnection con2 = new MyDatabaseConnection("Server=other_server"); MyDatabaseConnection con3 = new MyDatabaseConnection("Server=third_one"); MyDatabaseConnection[] cons = new MyDatabaseConnection[] { con1, con2, con3 }; foreach (MyDatabaseConnection con in cons) { con.execute(query); } }
public void searchOnAllDatabases(string query) { MyDatabaseConnection con1 = new MyDatabaseConnection("Data Source= 10.232.1.15\\SERVER1;Initial Catalog = My Catalog;Persist Security Info=True;User ID=sa;Password=myPSW"); //----1st search here MyDatabaseConnection con2 = new MyDatabaseConnection("Data Source= 10.232.1.15\\SERVER2;Initial Catalog = My Catalog;Persist Security Info=True;User ID=sa;Password=myPSW"); //---- 2nd search here MyDatabaseConnection con3 = new MyDatabaseConnection("Data Source= 10.232.1.15\\SERVER3;Initial Catalog = My Catalog;Persist Security Info=True;User ID=sa;Password=myPSW"); //---- 3rd search here MyDatabaseConnection[] cons = new MyDatabaseConnection[] { con1, con2, con3 }; foreach (MyDatabaseConnection con in cons) { var result = con.execute(query); if (result) { break; } } }