public void  executeScriptOnDestinationServer(string script)
 {
     try{
         using (SqlConnection serverConnection = new SqlConnection(destination)){
             SqlCommand cmd = new SqlCommand(script, serverConnection);
             Console.WriteLine("Executing script: " + script);
             DataUtilLibrary.writeToLog("Executing script: " + script + " on source database.");
             cmd.CommandTimeout = 0;
             serverConnection.Open();
             cmd.ExecuteNonQuery();
         }
     }catch (Exception e) {
         DataUtilLibrary.writeToLog("Error while running script: " + e.Message);
         DataUtilLibrary.writeToLog(e.StackTrace);
     }
 }
        public bool initSourceConnectionString()
        {
            bool canConnect = false;

            try
            {
                sourceConnectionString = @"Network Library=DBMSSOCN;Data Source=" + sourceServer + "," + sourcePort + ";database=" + sourceDatabase + ";User id=officeadmin;Password=AdminOfficer123;Connection Timeout=0;Pooling=false;Packet Size=16384;";
                SqlConnection serverConnection = new SqlConnection(sourceConnectionString);
                serverConnection.Open();
                canConnect = true;
                serverConnection.Close();
            }catch (Exception e) {
                DataUtilLibrary.writeToLog("Error connecting to server: " + e.Message);
                DataUtilLibrary.writeToLog(e.StackTrace);
            }
            return(canConnect);
        }
        public bool initDestinationConnectionString()
        {
            bool canConnect = false;

            try
            {
                destinationConnectionString = @"Network Library=DBMSSOCN;Data Source=" + destinationServer + "," + destinationPort + ";database=" + destinationDatabase + ";Trusted_Connection=True;Connection Timeout=0;Pooling=false;Packet Size=16384;";

                SqlConnection serverConnection = new SqlConnection(destinationConnectionString);
                serverConnection.Open();
                canConnect = true;
                serverConnection.Close();
            }catch (Exception e) {
                DataUtilLibrary.writeToLog("Error while running script: " + e.Message);
                DataUtilLibrary.writeToLog(e.StackTrace);
            }
            return(canConnect);
        }
 public System.Data.DataTable   getDataFromDestinationDatabase(string script)
 {
     System.Data.DataTable dt = new DataTable();
     try{
         using (SqlConnection serverConnection = new SqlConnection(destinationConnectionString)){
             SqlCommand cmd = new SqlCommand(script, serverConnection);
             DataUtilLibrary.writeToLog("Executing script: " + script + " on destination database.");
             cmd.CommandTimeout = 0;
             serverConnection.Open();
             SqlDataReader reader = cmd.ExecuteReader();
             dt.Load(reader);
             cmd.Dispose();
         }
     }catch (Exception e) {
         DataUtilLibrary.writeToLog("Error while running script: " + e.Message);
         DataUtilLibrary.writeToLog(e.StackTrace);
     }
     return(dt);
 }